Skip to content

Commit

Permalink
chore: add missing vote functions and fix misc bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mootz12 committed Mar 26, 2024
1 parent 899698b commit 1fad24f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.0",
"version": "0.5.0",
"name": "soroban-governor-js-sdk",
"dependencies": {
"@stellar/freighter-api": "1.7.1",
Expand Down
4 changes: 2 additions & 2 deletions src/governor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export enum ProposalStatus {
}

export class GovernorContract extends Contract {
static readonly spec = new ContractSpec([
static spec = new ContractSpec([
"AAAAAAAAAAAAAAAKaW5pdGlhbGl6ZQAAAAAAAgAAAAAAAAAFdm90ZXMAAAAAAAATAAAAAAAAAAhzZXR0aW5ncwAAB9AAAAAQR292ZXJub3JTZXR0aW5ncwAAAAA=",
"AAAAAAAAAAAAAAAIc2V0dGluZ3MAAAAAAAAAAQAAB9AAAAAQR292ZXJub3JTZXR0aW5ncw==",
"AAAAAAAAAAAAAAAHcHJvcG9zZQAAAAAEAAAAAAAAAAdjcmVhdG9yAAAAABMAAAAAAAAABXRpdGxlAAAAAAAAEAAAAAAAAAALZGVzY3JpcHRpb24AAAAAEAAAAAAAAAAGYWN0aW9uAAAAAAfQAAAADlByb3Bvc2FsQWN0aW9uAAAAAAABAAAABA==",
Expand All @@ -277,7 +277,7 @@ export class GovernorContract extends Contract {
"AAAAAgAAAWZUaGUgYWN0aW9uIHRvIGJlIHRha2VuIGJ5IGEgcHJvcG9zYWwuCgojIyMgQ2FsbGRhdGEKVGhlIHByb3Bvc2FsIHdpbGwgZXhlY3V0ZSB0aGUgY2FsbGRhdGEgZnJvbSB0aGUgZ292ZXJub3IgY29udHJhY3Qgb24gZXhlY3V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bm90IGJlZW4gY2xvc2VkAAAAAAAET3BlbgAAAAAAAABqVGhlIHByb3Bvc2FsIHdhcyB2b3RlZCBmb3IuIElmIHRoZSBwcm9wb3NhbCBpcyBleGVjdXRhYmxlLCB0aGUgdGltZWxvY2sgYmVnaW5zIG9uY2UgdGhpcyBzdGF0ZSBpcyByZWFjaGVkLgAAAAAAClN1Y2Nlc3NmdWwAAAAAAAEAAAAeVGhlIHByb3Bvc2FsIHdhcyB2b3RlZCBhZ2FpbnN0AAAAAAAIRGVmZWF0ZWQAAAACAAAAbVRoZSBwcm9wb3NhbCBkaWQgbm90IHJlYWNoIHF1b3J1bSBiZWZvcmUgdGhlIHZvdGluZyBwZXJpb2QgZW5kZWQsIG9yIHdhcyBzdGFsbGVkIG91dCBkdXJpbmcgdGhlIGdyYWNlIHBlcmlvZC4AAAAAAAAHRXhwaXJlZAAAAAADAAAAHlRoZSBwcm9wb3NhbCBoYXMgYmVlbiBleGVjdXRlZAAAAAAACEV4ZWN1dGVkAAAABAAAAB5UaGUgcHJvcG9zYWwgaGFzIGJlZW4gY2FuY2VsZWQAAAAAAAhDYW5jZWxlZAAAAAU=",
]);

static readonly parsers = {
Expand Down
45 changes: 44 additions & 1 deletion src/votes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export class StakingVotesContract extends Contract {
...StakingVotesContract.spec.funcArgsToScVals("initialize", {
token: new Address(token),
governor: new Address(governor),
name,
symbol,
})
).toXDR("base64");
}
Expand Down Expand Up @@ -334,7 +336,7 @@ export class StakingVotesContract extends Contract {
*/
withdraw({ from, amount }: { from: string; amount: i128 }): string {
return this.call(
"withdraw_to",
"withdraw",
...StakingVotesContract.spec.funcArgsToScVals("withdraw", {
from: new Address(from),
amount,
Expand Down Expand Up @@ -756,4 +758,45 @@ export class TokenVotesContract extends Contract {
})
).toXDR("base64");
}

/**
* Construct a mint operation
* @param to The address of the account to mint to
* @param amount The amount of tokens to mint
* @returns A base64 XDR string of the operation
*/
mint({ to, amount }: { to: string; amount: i128 }): string {
return this.call(
"mint",
...TokenVotesContract.spec.funcArgsToScVals("mint", {
to: new Address(to),
amount,
})
).toXDR("base64");
}

/**
* Construct a set_admin operation
* @param new_admin The address of the account to set the admin as
* @returns A base64 XDR string of the operation
*/
setAdmin({ new_admin }: { new_admin: string }): string {
return this.call(
"set_admin",
...TokenVotesContract.spec.funcArgsToScVals("set_admin", {
new_admin: new Address(new_admin),
})
).toXDR("base64");
}

/**
* Construct a get admin operation (READ ONLY: Operation should only be simulated)
* @returns A base64 XDR string of the operation
*/
admin(): string {
return this.call(
"admin",
...TokenVotesContract.spec.funcArgsToScVals("admin", {})
).toXDR("base64");
}
}

0 comments on commit 1fad24f

Please sign in to comment.