-
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.
Apply the changes of lbm v0.4.0-rc1 (#25)
* feat: apply lbm-sdk v0.46.0-rc1 - add `x/foundation` module Signed-off-by: zemyblue <[email protected]> * chore: change the version to `0.4.0-rc2`. Signed-off-by: zemyblue <[email protected]> * fix: fix faucet docker bug of issue #24. Signed-off-by: zemyblue <[email protected]> * feat: add x/foundation unittest and tx encodeObject. Signed-off-by: zemyblue <[email protected]> * feat: add `UpdateDecisionPolicy` unittest Signed-off-by: zemyblue <[email protected]>
- Loading branch information
Showing
18 changed files
with
557 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
.yarn/cache/lbmjs-types-npm-0.46.0-rc1-85a2c1c7cb-72ca870440.zip
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
.yarn/cache/lbmjs-types-npm-0.46.0-rc2-d0ca857389-07b1125ff6.zip
Git LFS file not shown
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/amino", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "Helpers for Amino based signing which are shared @lbmjs/proto-signing.", | ||
"contributors": [ | ||
"Simon Warta <[email protected]>", | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/cosmwasm-stargate", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "LBM(CosmWasm) SDK", | ||
"contributors": [ | ||
"Will Clark <[email protected]>", | ||
|
@@ -43,7 +43,7 @@ | |
"@lbmjs/ostracon-rpc": "workspace:packages/ostracon-rpc", | ||
"@lbmjs/proto-signing": "workspace:packages/proto-signing", | ||
"@lbmjs/stargate": "workspace:packages/stargate", | ||
"lbmjs-types": "^0.46.0-rc1", | ||
"lbmjs-types": "^0.46.0-rc2", | ||
"long": "^4.0.0", | ||
"pako": "^2.0.2", | ||
"protobufjs": "~6.10.2" | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/faucet-client", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "The faucet client", | ||
"contributors": [ | ||
"Will Clark <[email protected]>", | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/faucet", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "The faucet", | ||
"contributors": [ | ||
"Ethan Frey <[email protected]>", | ||
|
@@ -32,7 +32,8 @@ | |
"test-node": "yarn node jasmine-testrunner.js", | ||
"test": "yarn build-or-skip && yarn test-node", | ||
"coverage": "nyc --reporter=text --reporter=lcov yarn test --quiet", | ||
"start-dev": "FAUCET_ADDRESS_PREFIX=link FAUCET_CREDIT_AMOUNT_CONY=10000000 FAUCET_CREDIT_AMOUNT_STAKE=100000 FAUCET_CONCURRENCY=3 FAUCET_MNEMONIC=\"mind flame tobacco sense move hammer drift crime ring globe art gaze cinnamon helmet cruise special produce notable negative wait path scrap recall have\" ./bin/lbm-faucet start \"localhost:26657\"" | ||
"start-dev": "FAUCET_ADDRESS_PREFIX=link FAUCET_CREDIT_AMOUNT_CONY=10000000 FAUCET_CREDIT_AMOUNT_STAKE=100000 FAUCET_CONCURRENCY=3 FAUCET_MNEMONIC=\"mind flame tobacco sense move hammer drift crime ring globe art gaze cinnamon helmet cruise special produce notable negative wait path scrap recall have\" ./bin/lbm-faucet start \"localhost:26657\"", | ||
"pack-node": "yarn build-or-skip && webpack --mode production --config webpack.node.config.js" | ||
}, | ||
"dependencies": { | ||
"@cosmjs/crypto": "0.28.4", | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/ostracon-rpc", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "Ostracon RPC clients", | ||
"contributors": [ | ||
"IOV SAS <[email protected]>", | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/proto-signing", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "Utilities for protobuf based signing (LBM SDK 0.45.0)", | ||
"contributors": [ | ||
"Will Clark <[email protected]>", | ||
|
@@ -40,7 +40,7 @@ | |
"@cosmjs/crypto": "0.28.4", | ||
"@cosmjs/math": "0.28.4", | ||
"@lbmjs/amino": "workspace:packages/amino", | ||
"lbmjs-types": "^0.46.0-rc1", | ||
"lbmjs-types": "^0.46.0-rc2", | ||
"long": "^4.0.0", | ||
"protobufjs": "~6.10.2" | ||
}, | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@lbmjs/stargate", | ||
"version": "0.4.0-rc1", | ||
"version": "0.4.0-rc2", | ||
"description": "Utilities for LBM SDK 0.45.0-rc0", | ||
"contributors": [ | ||
"Simon Warta <[email protected]>", | ||
|
@@ -43,7 +43,7 @@ | |
"@lbmjs/amino": "workspace:packages/amino", | ||
"@lbmjs/ostracon-rpc": "workspace:packages/ostracon-rpc", | ||
"@lbmjs/proto-signing": "workspace:packages/proto-signing", | ||
"lbmjs-types": "^0.46.0-rc1", | ||
"lbmjs-types": "^0.46.0-rc2", | ||
"long": "^4.0.0", | ||
"protobufjs": "~6.10.2", | ||
"xstream": "^11.14.0" | ||
|
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,199 @@ | ||
import { Decimal } from "@cosmjs/math"; | ||
import { EncodeObject, GeneratedType } from "@lbmjs/proto-signing/build"; | ||
import { Duration } from "lbmjs-types/google/protobuf/duration"; | ||
import { Coin } from "lbmjs-types/lbm/base/v1/coin"; | ||
import { ReceiveFromTreasuryAuthorization } from "lbmjs-types/lbm/foundation/v1/authz"; | ||
import { | ||
DecisionPolicyWindows, | ||
Member, | ||
PercentageDecisionPolicy, | ||
ThresholdDecisionPolicy, | ||
} from "lbmjs-types/lbm/foundation/v1/foundation"; | ||
import { | ||
Exec, | ||
MsgExec, | ||
MsgFundTreasury, | ||
MsgGrant, | ||
MsgLeaveFoundation, | ||
MsgRevoke, | ||
MsgSubmitProposal, | ||
MsgUpdateDecisionPolicy, | ||
MsgUpdateMembers, | ||
MsgVote, | ||
MsgWithdrawFromTreasury, | ||
MsgWithdrawProposal, | ||
} from "lbmjs-types/lbm/foundation/v1/tx"; | ||
|
||
import { longify } from "../../queryclient"; | ||
|
||
export const foundationTypes: ReadonlyArray<[string, GeneratedType]> = [ | ||
["/lbm.foundation.v1.MsgFundTreasury", MsgFundTreasury], | ||
["/lbm.foundation.v1.MsgWithdrawFromTreasury", MsgWithdrawFromTreasury], | ||
["/lbm.foundation.v1.MsgUpdateMembers", MsgUpdateMembers], | ||
["/lbm.foundation.v1.MsgUpdateDecisionPolicy", MsgUpdateDecisionPolicy], | ||
["/lbm.foundation.v1.MsgSubmitProposal", MsgSubmitProposal], | ||
["/lbm.foundation.v1.MsgWithdrawProposal", MsgWithdrawProposal], | ||
["/lbm.foundation.v1.MsgVote", MsgVote], | ||
["/lbm.foundation.v1.MsgExec", MsgExec], | ||
["/lbm.foundation.v1.MsgLeaveFoundation", MsgLeaveFoundation], | ||
["/lbm.foundation.v1.MsgGrant", MsgGrant], | ||
["/lbm.foundation.v1.MsgRevoke", MsgRevoke], | ||
["/lbm.foundation.v1.ReceiveFromTreasuryAuthorization", ReceiveFromTreasuryAuthorization], | ||
["/lbm.foundation.v1.DecisionPolicyWindows", DecisionPolicyWindows], | ||
["/lbm.foundation.v1.ThresholdDecisionPolicy", ThresholdDecisionPolicy], | ||
["/lbm.foundation.v1.PercentageDecisionPolicy", PercentageDecisionPolicy], | ||
]; | ||
|
||
export function createMsgSubmitProposal( | ||
proposers: string[], | ||
messages: EncodeObject[], | ||
metadata = "", | ||
exec: Exec = Exec.EXEC_TRY, | ||
): EncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.MsgSubmitProposal", | ||
value: { | ||
proposers: proposers, | ||
metadata: metadata, | ||
messages: messages, | ||
exec: exec, | ||
}, | ||
}; | ||
} | ||
|
||
export function createMsgGrant(operator: string, grantee: string): EncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.MsgGrant", | ||
value: Uint8Array.from( | ||
MsgGrant.encode({ | ||
operator: operator, | ||
grantee: grantee, | ||
authorization: { | ||
typeUrl: "/lbm.foundation.v1.ReceiveFromTreasuryAuthorization", | ||
value: Uint8Array.from(ReceiveFromTreasuryAuthorization.encode({}).finish()), | ||
}, | ||
}).finish(), | ||
), | ||
}; | ||
} | ||
|
||
export function createMsgRevoke(operator: string, grantee: string, msgTypeUrl: string): EncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.MsgRevoke", | ||
value: Uint8Array.from( | ||
MsgRevoke.encode({ | ||
operator: operator, | ||
grantee: grantee, | ||
msgTypeUrl: msgTypeUrl, | ||
}).finish(), | ||
), | ||
}; | ||
} | ||
|
||
export function createMsgWithdrawFromTreasury( | ||
operator: string, | ||
toAddress: string, | ||
amount: Coin[], | ||
): EncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.MsgWithdrawFromTreasury", | ||
value: Uint8Array.from( | ||
MsgWithdrawFromTreasury.encode({ | ||
operator: operator, | ||
to: toAddress, | ||
amount: amount, | ||
}).finish(), | ||
), | ||
}; | ||
} | ||
|
||
export function createMsgUpdateMembers(operator: string, members: Member[]): EncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.MsgUpdateMembers", | ||
value: Uint8Array.from( | ||
MsgUpdateMembers.encode({ | ||
operator: operator, | ||
memberUpdates: members, | ||
}).finish(), | ||
), | ||
}; | ||
} | ||
|
||
export function createMsgUpdateDecisionPolicy( | ||
operator: string, | ||
decisionPolicy: ThresholdDecisionPolicyEncodeObject | PercentageDecisionPolicyEncodeObject, | ||
): EncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.MsgUpdateDecisionPolicy", | ||
value: Uint8Array.from( | ||
MsgUpdateDecisionPolicy.encode({ | ||
operator: operator, | ||
decisionPolicy: decisionPolicy, | ||
}).finish(), | ||
), | ||
}; | ||
} | ||
|
||
export interface ThresholdDecisionPolicyEncodeObject extends EncodeObject { | ||
readonly typeUrl: "/lbm.foundation.v1.ThresholdDecisionPolicy"; | ||
readonly value: Uint8Array; | ||
} | ||
|
||
export function isThresholdDecisionPolicyEncodeObject( | ||
object: EncodeObject, | ||
): object is ThresholdDecisionPolicyEncodeObject { | ||
return ( | ||
(object as ThresholdDecisionPolicyEncodeObject).typeUrl === "/lbm.foundation.v1.ThresholdDecisionPolicy" | ||
); | ||
} | ||
|
||
export function createThresholdDecisionPolicy( | ||
threshold: string, | ||
votingPeriod = "86400", | ||
minExecutionPeriod = "0", | ||
): ThresholdDecisionPolicyEncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.ThresholdDecisionPolicy", | ||
value: Uint8Array.from( | ||
ThresholdDecisionPolicy.encode({ | ||
threshold: Decimal.fromUserInput(threshold, 18).atomics, | ||
windows: { | ||
votingPeriod: Duration.fromPartial({ seconds: longify(votingPeriod) }), | ||
minExecutionPeriod: Duration.fromPartial({ seconds: longify(minExecutionPeriod) }), | ||
}, | ||
}).finish(), | ||
), | ||
}; | ||
} | ||
|
||
export interface PercentageDecisionPolicyEncodeObject extends EncodeObject { | ||
readonly typeUrl: "/lbm.foundation.v1.PercentageDecisionPolicy"; | ||
readonly value: Uint8Array; | ||
} | ||
|
||
export function isPercentageDecisionPolicyEncodeObject( | ||
object: EncodeObject, | ||
): object is PercentageDecisionPolicyEncodeObject { | ||
return ( | ||
(object as PercentageDecisionPolicyEncodeObject).typeUrl === "/lbm.foundation.v1.PercentageDecisionPolicy" | ||
); | ||
} | ||
|
||
export function createPercentageDecisionPolicy( | ||
percentage: string, | ||
votingPeriod = "86400", | ||
minExecutionPeriod = "0", | ||
): PercentageDecisionPolicyEncodeObject { | ||
return { | ||
typeUrl: "/lbm.foundation.v1.PercentageDecisionPolicy", | ||
value: Uint8Array.from( | ||
PercentageDecisionPolicy.encode({ | ||
percentage: Decimal.fromUserInput(percentage, 18).atomics, | ||
windows: { | ||
votingPeriod: Duration.fromPartial({ seconds: longify(votingPeriod) }), | ||
minExecutionPeriod: Duration.fromPartial({ seconds: longify(minExecutionPeriod) }), | ||
}, | ||
}).finish(), | ||
), | ||
}; | ||
} |
Oops, something went wrong.