-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
172 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; | ||
import { SigningStargateClient } from "@cosmjs/stargate"; | ||
|
||
// import the required message type from akashjs | ||
import { getAkashTypeRegistry, getTypeUrl } from "@akashnetwork/akashjs/build/src/stargate/index"; | ||
import { MsgCloseDeployment } from "@akashnetwork/akashjs/build/src/protobuf/akash/deployment/v1beta1/deployment"; | ||
|
||
|
||
async function main() { | ||
const mnemonic = "your wallet mnemonic"; | ||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" }); | ||
|
||
// get first account | ||
const [account] = await wallet.getAccounts(); | ||
|
||
// Use the encode method for the message to wrap the data | ||
const message = MsgCloseDeployment.fromPartial({ | ||
id: { | ||
dseq: "555555", | ||
owner: account.address, | ||
} | ||
}); | ||
|
||
// Set the appropriate typeUrl and attach the encoded message as the value | ||
const msgAny = { | ||
typeUrl: getTypeUrl(MsgCloseDeployment), | ||
value: message | ||
}; | ||
|
||
// You can use your own RPC node, or get a list of public nodes from akashjs | ||
const rpcEndpoint = "http://my.rpc.node"; | ||
|
||
const myRegistry = new Registry( | ||
getAkashTypeRegistry() | ||
); | ||
|
||
const client = await SigningStargateClient.connectWithSigner( | ||
rpcEndpoint, | ||
wallet, | ||
{ | ||
registry: myRegistry | ||
} | ||
); | ||
|
||
const gas = await client.simulate( | ||
account.address, | ||
[msgAny], | ||
"take down deployment" | ||
); | ||
|
||
console.log(gas); | ||
} | ||
|
||
main(); |
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,60 @@ | ||
import { coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; | ||
import { defaultRegistryTypes, SigningStargateClient } from "@cosmjs/stargate"; | ||
|
||
async function main() { | ||
|
||
const mnemonic = "your wallet mnemonic"; | ||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" }); | ||
|
||
// get first account | ||
const [account] = await wallet.getAccounts(); | ||
|
||
// Setup a send message | ||
const message = { | ||
fromAddress: account.address, | ||
toAddress: "akash123...", | ||
amount: coins(10, "akt"), | ||
}; | ||
|
||
// Set the appropriate typeUrl and attach the encoded message as the value | ||
const msgAny = { | ||
typeUrl: '/cosmos.bank.v1beta1.MsgSend', | ||
value: message | ||
}; | ||
|
||
// You can use your own RPC node, or get a list of public nodes from akashjs | ||
const rpcEndpoint = "http://your.rpc.node"; | ||
|
||
const myRegistry = new Registry( | ||
defaultRegistryTypes | ||
); | ||
|
||
const client = await SigningStargateClient.connectWithSigner( | ||
rpcEndpoint, | ||
wallet, | ||
{ | ||
registry: myRegistry | ||
} | ||
); | ||
|
||
const fee = { | ||
amount: [ | ||
{ | ||
denom: "uakt", | ||
amount: "5000", | ||
}, | ||
], | ||
gas: "800000", | ||
}; | ||
|
||
const msg = await client.sign( | ||
account.address, | ||
[msgAny], | ||
fee, | ||
"take down deployment" | ||
); | ||
|
||
console.log(msg); | ||
} | ||
|
||
main(); |