-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from maestro-org/feat/contracts/linear-vesting
feat: contracts/linear-vesting
- Loading branch information
Showing
8 changed files
with
193 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/maestro-org/go-sdk/models" | ||
) | ||
|
||
type LockBody struct { | ||
Sender string `json:"sender"` | ||
Beneficiary string `json:"beneficiary"` | ||
AssetPolicyId string `json:"asset_policy_id"` | ||
AssetTokenName string `json:"asset_token_name"` | ||
TotalVestingQuantity int64 `json:"total_vesting_quantity"` | ||
VestingPeriodStart int64 `json:"vesting_period_start"` | ||
VestingPeriodEnd int64 `json:"vesting_period_end"` | ||
FirstUnlockPossibleAfter int64 `json:"first_unlock_possible_after"` | ||
TotalInstallments int64 `json:"total_installments"` | ||
} | ||
|
||
func (c *Client) LockAssets(lockBody LockBody) (*models.LockTransaction, error) { | ||
url := "/contracts/vesting/lock" | ||
|
||
body := lockBody | ||
resp, err := c.post(url, body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var lockTransaction models.LockTransaction | ||
err = json.NewDecoder(resp.Body).Decode(&lockTransaction) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &lockTransaction, nil | ||
} | ||
|
||
func (c *Client) StateOfVestingAssets(beneficiary string) (*[]models.VestingState, error) { | ||
url := fmt.Sprintf("/contracts/vesting/state/%s", beneficiary) | ||
resp, err := c.get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var vestingStates []models.VestingState | ||
err = json.NewDecoder(resp.Body).Decode(&vestingStates) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &vestingStates, nil | ||
|
||
} | ||
|
||
func (c *Client) CollectAssets(beneficiary string) (*models.CollectTransaction, error) { | ||
url := fmt.Sprintf("/contracts/vesting/collect/%s", beneficiary) | ||
resp, err := c.post(url, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
var collectTransaction models.CollectTransaction | ||
err = json.NewDecoder(resp.Body).Decode(&collectTransaction) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &collectTransaction, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.