@sodax/sdk 0.0.1-rc.6 → 0.0.1-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +12 -12
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -19
- package/dist/constants.js.map +1 -1
- package/dist/entities/Providers.d.ts +3 -5
- package/dist/entities/Providers.d.ts.map +1 -1
- package/dist/entities/Providers.js +0 -2
- package/dist/entities/Providers.js.map +1 -1
- package/dist/entities/cosmos/CW20Token.d.ts +5 -5
- package/dist/entities/cosmos/CW20Token.d.ts.map +1 -1
- package/dist/entities/cosmos/CW20Token.js +6 -6
- package/dist/entities/cosmos/CW20Token.js.map +1 -1
- package/dist/entities/cosmos/CWSpokeProvider.d.ts +8 -22
- package/dist/entities/cosmos/CWSpokeProvider.d.ts.map +1 -1
- package/dist/entities/cosmos/CWSpokeProvider.js +6 -22
- package/dist/entities/cosmos/CWSpokeProvider.js.map +1 -1
- package/dist/entities/icon/IconSpokeProvider.d.ts +2 -2
- package/dist/entities/icon/IconSpokeProvider.d.ts.map +1 -1
- package/dist/entities/icon/IconSpokeProvider.js +2 -2
- package/dist/entities/icon/IconSpokeProvider.js.map +1 -1
- package/dist/entities/solana/Configs.d.ts +9 -37
- package/dist/entities/solana/Configs.d.ts.map +1 -1
- package/dist/entities/solana/Configs.js +38 -137
- package/dist/entities/solana/Configs.js.map +1 -1
- package/dist/services/spoke/IconSpokeService.d.ts.map +1 -1
- package/dist/services/spoke/IconSpokeService.js +11 -8
- package/dist/services/spoke/IconSpokeService.js.map +1 -1
- package/dist/services/spoke/SolanaSpokeService.js +15 -7
- package/dist/services/spoke/SolanaSpokeService.js.map +1 -1
- package/dist/types.d.ts +1 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/entities/cosmos/CosmosWalletProvider.d.ts +0 -28
- package/dist/entities/cosmos/CosmosWalletProvider.d.ts.map +0 -1
- package/dist/entities/cosmos/CosmosWalletProvider.js +0 -102
- package/dist/entities/cosmos/CosmosWalletProvider.js.map +0 -1
- package/dist/entities/cosmos/InjectiveWalletProvider.d.ts +0 -25
- package/dist/entities/cosmos/InjectiveWalletProvider.d.ts.map +0 -1
- package/dist/entities/cosmos/InjectiveWalletProvider.js +0 -76
- package/dist/entities/cosmos/InjectiveWalletProvider.js.map +0 -1
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type JsonObject, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
2
|
-
import { type Coin, type OfflineSigner } from '@cosmjs/proto-signing';
|
|
3
|
-
import { type StdFee } from '@cosmjs/stargate';
|
|
4
|
-
import type { CWRawTransaction, CosmosNetworkEnv, Hex } from '../../index.js';
|
|
5
|
-
import { ExecuteResponse, type ICWWalletProvider } from './CWSpokeProvider.js';
|
|
6
|
-
export interface CosmosWalletConfig {
|
|
7
|
-
prefix: string;
|
|
8
|
-
mnemonics: string;
|
|
9
|
-
network: CosmosNetworkEnv;
|
|
10
|
-
rpcUrl: string;
|
|
11
|
-
gasPrice: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class CosmosWalletProvider implements ICWWalletProvider {
|
|
14
|
-
private client;
|
|
15
|
-
private config;
|
|
16
|
-
private wallet;
|
|
17
|
-
private address;
|
|
18
|
-
pubkey: Uint8Array | undefined;
|
|
19
|
-
constructor(config: CosmosWalletConfig);
|
|
20
|
-
getRawTransaction(chainId: string, prefix: string, senderAddress: string, contractAddress: string, msg: JsonObject, memo?: string): CWRawTransaction;
|
|
21
|
-
getClient(): Promise<SigningCosmWasmClient>;
|
|
22
|
-
getWallet(): Promise<OfflineSigner>;
|
|
23
|
-
getWalletAddress(): Promise<string>;
|
|
24
|
-
getWalletAddressBytes(): Promise<Hex>;
|
|
25
|
-
execute(senderAddress: string, contractAddress: string, msg: JsonObject, fee: StdFee | 'auto' | number, memo?: string, funds?: Coin[]): Promise<ExecuteResponse>;
|
|
26
|
-
queryContractSmart(address: string, queryMsg: JsonObject): Promise<JsonObject>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=CosmosWalletProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosWalletProvider.d.ts","sourceRoot":"","sources":["../../../src/entities/cosmos/CosmosWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,KAAK,IAAI,EAA2B,KAAK,aAAa,EAAgB,MAAM,uBAAuB,CAAC;AAC7G,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAMzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG/E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,oBAAqB,YAAW,iBAAiB;IAC5D,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,OAAO,CAAqB;IAC7B,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;gBAE1B,MAAM,EAAE,kBAAkB;IAGtC,iBAAiB,CACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,UAAU,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB;IA2Cb,SAAS,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAU3C,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAgBnC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAOnC,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC;IAIrC,OAAO,CACX,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC7B,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,IAAI,EAAE,GACb,OAAO,CAAC,eAAe,CAAC;IAKrB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAIrF"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
2
|
-
import { DirectSecp256k1HdWallet, encodePubkey } from '@cosmjs/proto-signing';
|
|
3
|
-
import { GasPrice } from '@cosmjs/stargate';
|
|
4
|
-
import { AuthInfo, SignerInfo, TxBody } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
5
|
-
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx.js';
|
|
6
|
-
import { toHex } from 'viem';
|
|
7
|
-
import { ExecuteResponse } from './CWSpokeProvider.js';
|
|
8
|
-
export class CosmosWalletProvider {
|
|
9
|
-
client;
|
|
10
|
-
config;
|
|
11
|
-
wallet;
|
|
12
|
-
address;
|
|
13
|
-
pubkey;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
this.config = config;
|
|
16
|
-
}
|
|
17
|
-
getRawTransaction(chainId, prefix, senderAddress, contractAddress, msg, memo) {
|
|
18
|
-
const msgExecuteContract = MsgExecuteContract.fromPartial({
|
|
19
|
-
sender: senderAddress,
|
|
20
|
-
contract: contractAddress,
|
|
21
|
-
msg: msg,
|
|
22
|
-
funds: [],
|
|
23
|
-
});
|
|
24
|
-
const msgAny = {
|
|
25
|
-
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
|
26
|
-
value: MsgExecuteContract.encode(msgExecuteContract).finish(),
|
|
27
|
-
};
|
|
28
|
-
const txBody = TxBody.fromPartial({
|
|
29
|
-
messages: [msgAny],
|
|
30
|
-
memo: memo || '',
|
|
31
|
-
});
|
|
32
|
-
const bodyBytes = TxBody.encode(txBody).finish();
|
|
33
|
-
if (!this.pubkey) {
|
|
34
|
-
throw new Error('[CosmosWalletProvider] ppubkey is undefined');
|
|
35
|
-
}
|
|
36
|
-
const signerInfo = SignerInfo.fromPartial({
|
|
37
|
-
publicKey: encodePubkey({
|
|
38
|
-
type: 'tendermint/PubKeySecp256k1',
|
|
39
|
-
value: Buffer.from(this.pubkey).toString('base64'),
|
|
40
|
-
}),
|
|
41
|
-
sequence: BigInt(0),
|
|
42
|
-
});
|
|
43
|
-
const authInfo = AuthInfo.fromPartial({
|
|
44
|
-
signerInfos: [signerInfo],
|
|
45
|
-
});
|
|
46
|
-
const authInfoBytes = AuthInfo.encode(authInfo).finish();
|
|
47
|
-
return {
|
|
48
|
-
from: senderAddress,
|
|
49
|
-
to: contractAddress,
|
|
50
|
-
signedDoc: {
|
|
51
|
-
bodyBytes: bodyBytes,
|
|
52
|
-
chainId: chainId,
|
|
53
|
-
accountNumber: BigInt(0),
|
|
54
|
-
authInfoBytes: authInfoBytes,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
async getClient() {
|
|
59
|
-
if (this.client === undefined) {
|
|
60
|
-
const wallet = await this.getWallet();
|
|
61
|
-
this.client = await SigningCosmWasmClient.connectWithSigner(this.config.rpcUrl, wallet, {
|
|
62
|
-
gasPrice: GasPrice.fromString(this.config.gasPrice), // Adjust according to your chain
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return this.client;
|
|
66
|
-
}
|
|
67
|
-
async getWallet() {
|
|
68
|
-
if (this.wallet === undefined) {
|
|
69
|
-
this.wallet = await DirectSecp256k1HdWallet.fromMnemonic(this.config.mnemonics, {
|
|
70
|
-
prefix: this.config.prefix, // Change this according to your chain
|
|
71
|
-
});
|
|
72
|
-
const accounts = await this.wallet.getAccounts();
|
|
73
|
-
if (accounts.length > 0 && accounts[0]) {
|
|
74
|
-
this.address = accounts[0].address;
|
|
75
|
-
this.pubkey = accounts[0].pubkey;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
throw Error('Failed to get Account');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return this.wallet;
|
|
82
|
-
}
|
|
83
|
-
async getWalletAddress() {
|
|
84
|
-
if (this.address) {
|
|
85
|
-
return Promise.resolve(this.address);
|
|
86
|
-
}
|
|
87
|
-
throw Error('Address Not Set');
|
|
88
|
-
}
|
|
89
|
-
async getWalletAddressBytes() {
|
|
90
|
-
return toHex(Buffer.from(await this.getWalletAddress(), 'utf-8'));
|
|
91
|
-
}
|
|
92
|
-
async execute(senderAddress, contractAddress, msg, fee, memo, funds) {
|
|
93
|
-
const client = await this.getClient();
|
|
94
|
-
const res = await client.execute(senderAddress, contractAddress, msg, fee, memo, funds);
|
|
95
|
-
return ExecuteResponse.fromExecResult(res);
|
|
96
|
-
}
|
|
97
|
-
async queryContractSmart(address, queryMsg) {
|
|
98
|
-
const client = await this.getClient();
|
|
99
|
-
return client.queryContractSmart(address, queryMsg);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=CosmosWalletProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosWalletProvider.js","sourceRoot":"","sources":["../../../src/entities/cosmos/CosmosWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAa,uBAAuB,EAAsB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7G,OAAO,EAAE,QAAQ,EAAe,MAAM,kBAAk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C;IACD,KAAK,CAAC,kBAAkB,CAAC,OAAe,EAAE,QAAoB;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CosmWasmClient, type JsonObject } from '@cosmjs/cosmwasm-stargate';
|
|
2
|
-
import type { Coin } from '@cosmjs/proto-signing';
|
|
3
|
-
import type { StdFee } from '@cosmjs/stargate';
|
|
4
|
-
import type { CosmosNetworkEnv, CWRawTransaction, Hex } from '../../index.js';
|
|
5
|
-
import { ExecuteResponse, type ICWWalletProvider } from './CWSpokeProvider.js';
|
|
6
|
-
export interface InjectiveWalletConfig {
|
|
7
|
-
mnemonics: string;
|
|
8
|
-
network: CosmosNetworkEnv;
|
|
9
|
-
rpcUrl: string;
|
|
10
|
-
}
|
|
11
|
-
export declare class InjectiveWalletProvider implements ICWWalletProvider {
|
|
12
|
-
private config;
|
|
13
|
-
private client;
|
|
14
|
-
private cosmosClient;
|
|
15
|
-
private address;
|
|
16
|
-
pubkey: Uint8Array;
|
|
17
|
-
constructor(config: InjectiveWalletConfig);
|
|
18
|
-
getRawTransaction(chainId: string, _: string, senderAddress: string, contractAddress: string, msg: JsonObject, memo?: string): CWRawTransaction;
|
|
19
|
-
getCosmwasmClient(): Promise<CosmWasmClient>;
|
|
20
|
-
getWalletAddress(): Promise<string>;
|
|
21
|
-
getWalletAddressBytes(): Promise<Hex>;
|
|
22
|
-
execute(senderAddress: string, contractAddress: string, msg: JsonObject, fee: StdFee | 'auto' | number, memo?: string, funds?: Coin[]): Promise<ExecuteResponse>;
|
|
23
|
-
queryContractSmart(address: string, queryMsg: JsonObject): Promise<JsonObject>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=InjectiveWalletProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1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,EAC7B,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,IAAI,EAAE,GACb,OAAO,CAAC,eAAe,CAAC;IAWrB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAIrF"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
2
|
-
import { Network } from '@injectivelabs/networks';
|
|
3
|
-
import { MsgBroadcasterWithPk, PrivateKey, MsgExecuteContract, createTransaction } from '@injectivelabs/sdk-ts';
|
|
4
|
-
import { ExecuteResponse } from './CWSpokeProvider.js';
|
|
5
|
-
import { DEFAULT_GAS_LIMIT } from '@injectivelabs/utils';
|
|
6
|
-
import { toHex } from 'viem';
|
|
7
|
-
export class InjectiveWalletProvider {
|
|
8
|
-
config;
|
|
9
|
-
client;
|
|
10
|
-
cosmosClient;
|
|
11
|
-
address;
|
|
12
|
-
pubkey;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.config = config;
|
|
15
|
-
const privateKey = PrivateKey.fromMnemonic(config.mnemonics);
|
|
16
|
-
this.pubkey = privateKey.toPublicKey().toPubKeyBytes();
|
|
17
|
-
this.address = privateKey.toAddress().toBech32();
|
|
18
|
-
this.client = new MsgBroadcasterWithPk({
|
|
19
|
-
privateKey: privateKey,
|
|
20
|
-
network: this.config.network === 'Mainnet' ? Network.Mainnet : Network.Testnet,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
getRawTransaction(chainId, _, senderAddress, contractAddress, msg, memo) {
|
|
24
|
-
const msgExec = MsgExecuteContract.fromJSON({
|
|
25
|
-
contractAddress: contractAddress,
|
|
26
|
-
sender: senderAddress,
|
|
27
|
-
msg: msg,
|
|
28
|
-
funds: [],
|
|
29
|
-
});
|
|
30
|
-
const { txRaw } = createTransaction({
|
|
31
|
-
message: msgExec,
|
|
32
|
-
memo: '',
|
|
33
|
-
pubKey: Buffer.from(this.pubkey).toString(),
|
|
34
|
-
sequence: 0,
|
|
35
|
-
accountNumber: 0,
|
|
36
|
-
chainId: chainId,
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
from: senderAddress,
|
|
40
|
-
to: contractAddress,
|
|
41
|
-
signedDoc: {
|
|
42
|
-
bodyBytes: txRaw.bodyBytes,
|
|
43
|
-
chainId: chainId,
|
|
44
|
-
accountNumber: BigInt(0),
|
|
45
|
-
authInfoBytes: txRaw.authInfoBytes,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
async getCosmwasmClient() {
|
|
50
|
-
if (this.cosmosClient === undefined) {
|
|
51
|
-
this.cosmosClient = await CosmWasmClient.connect(this.config.rpcUrl);
|
|
52
|
-
}
|
|
53
|
-
return this.cosmosClient;
|
|
54
|
-
}
|
|
55
|
-
async getWalletAddress() {
|
|
56
|
-
return Promise.resolve(this.address);
|
|
57
|
-
}
|
|
58
|
-
async getWalletAddressBytes() {
|
|
59
|
-
return toHex(Buffer.from(await this.getWalletAddress(), 'utf-8'));
|
|
60
|
-
}
|
|
61
|
-
async execute(senderAddress, contractAddress, msg, fee, memo, funds) {
|
|
62
|
-
const msgExec = MsgExecuteContract.fromJSON({
|
|
63
|
-
contractAddress: contractAddress,
|
|
64
|
-
sender: senderAddress,
|
|
65
|
-
msg: msg,
|
|
66
|
-
funds: funds,
|
|
67
|
-
});
|
|
68
|
-
const txHash = await this.client.broadcast({ msgs: msgExec, gas: { gas: DEFAULT_GAS_LIMIT } });
|
|
69
|
-
return ExecuteResponse.fromTxResponse(txHash);
|
|
70
|
-
}
|
|
71
|
-
async queryContractSmart(address, queryMsg) {
|
|
72
|
-
const contractClient = await CosmWasmClient.connect(this.config.rpcUrl);
|
|
73
|
-
return contractClient.queryContractSmart(address, queryMsg);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=InjectiveWalletProvider.js.map
|
|
@@ -1 +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