@dynamic-labs/cosmos 4.73.0 → 4.73.2
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/CHANGELOG.md +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +6 -6
- package/src/wallet/CosmosWallet.cjs +51 -2
- package/src/wallet/CosmosWallet.d.ts +5 -1
- package/src/wallet/CosmosWallet.js +51 -2
- package/src/wallet/cosmosTransfer/broadcastAminoTx.cjs +33 -0
- package/src/wallet/cosmosTransfer/broadcastAminoTx.d.ts +2 -0
- package/src/wallet/cosmosTransfer/broadcastAminoTx.js +29 -0
- package/src/wallet/cosmosTransfer/buildBankSendMsg.cjs +24 -0
- package/src/wallet/cosmosTransfer/buildBankSendMsg.d.ts +7 -0
- package/src/wallet/cosmosTransfer/buildBankSendMsg.js +19 -0
- package/src/wallet/cosmosTransfer/buildCw20TransferMsg.cjs +26 -0
- package/src/wallet/cosmosTransfer/buildCw20TransferMsg.d.ts +3 -0
- package/src/wallet/cosmosTransfer/buildCw20TransferMsg.js +21 -0
- package/src/wallet/cosmosTransfer/fetchAccountSequence.cjs +23 -0
- package/src/wallet/cosmosTransfer/fetchAccountSequence.d.ts +5 -0
- package/src/wallet/cosmosTransfer/fetchAccountSequence.js +19 -0
- package/src/wallet/cosmosTransfer/index.d.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.73.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.73.1...v4.73.2) (2026-03-31)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* use initial URL for device registration redirect detection ([#10821](https://github.com/dynamic-labs/dynamic-auth/issues/10821)) ([dbec178](https://github.com/dynamic-labs/dynamic-auth/commit/dbec178e0bad9a7e99c529b79cb0fbe0fd347904))
|
|
8
|
+
|
|
9
|
+
### [4.73.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.73.0...v4.73.1) (2026-03-30)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **tempo:** add isTempoWallet type guard and TempoWallet class ([#10814](https://github.com/dynamic-labs/dynamic-auth/issues/10814)) ([1f2ec94](https://github.com/dynamic-labs/dynamic-auth/commit/1f2ec949bcfd25b2c460e07214041d06b172f12d))
|
|
15
|
+
|
|
2
16
|
## [4.73.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.72.0...v4.73.0) (2026-03-30)
|
|
3
17
|
|
|
4
18
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/cosmos",
|
|
3
|
-
"version": "4.73.
|
|
3
|
+
"version": "4.73.2",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@keplr-wallet/types": "0.12.121",
|
|
22
|
-
"@dynamic-labs/assert-package-version": "4.73.
|
|
23
|
-
"@dynamic-labs/types": "4.73.
|
|
24
|
-
"@dynamic-labs/utils": "4.73.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.73.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.73.
|
|
22
|
+
"@dynamic-labs/assert-package-version": "4.73.2",
|
|
23
|
+
"@dynamic-labs/types": "4.73.2",
|
|
24
|
+
"@dynamic-labs/utils": "4.73.2",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.73.2",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.73.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {}
|
|
29
29
|
}
|
|
@@ -6,11 +6,60 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
8
|
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
var broadcastAminoTx = require('./cosmosTransfer/broadcastAminoTx.cjs');
|
|
10
|
+
var buildBankSendMsg = require('./cosmosTransfer/buildBankSendMsg.cjs');
|
|
11
|
+
var buildCw20TransferMsg = require('./cosmosTransfer/buildCw20TransferMsg.cjs');
|
|
12
|
+
var fetchAccountSequence = require('./cosmosTransfer/fetchAccountSequence.cjs');
|
|
9
13
|
|
|
14
|
+
const DEFAULT_FEE_AMOUNT = '5000';
|
|
10
15
|
class CosmosWallet extends walletConnectorCore.Wallet {
|
|
11
16
|
sendBalance(_a) {
|
|
12
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
13
|
-
|
|
17
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, token, }) {
|
|
18
|
+
var _b, _c, _d, _e;
|
|
19
|
+
yield this._connector.connect();
|
|
20
|
+
const chainId = this._connector.getChainId();
|
|
21
|
+
const lcdUrl = this._connector.getLcdUrl();
|
|
22
|
+
const nativeDenom = this._connector.getDenom();
|
|
23
|
+
const fromAddress = this.address;
|
|
24
|
+
if (!lcdUrl) {
|
|
25
|
+
throw new Error('No LCD URL configured for this chain');
|
|
26
|
+
}
|
|
27
|
+
if (!nativeDenom) {
|
|
28
|
+
throw new Error('No native denom configured for this chain');
|
|
29
|
+
}
|
|
30
|
+
const { accountNumber, sequence } = yield fetchAccountSequence.fetchAccountSequence(lcdUrl, fromAddress);
|
|
31
|
+
const selectedChain = this._connector.getSelectedChain();
|
|
32
|
+
const nativeDecimals = (_c = (_b = selectedChain === null || selectedChain === void 0 ? void 0 : selectedChain.nativeCurrency) === null || _b === void 0 ? void 0 : _b.decimals) !== null && _c !== void 0 ? _c : buildBankSendMsg.DEFAULT_DECIMALS;
|
|
33
|
+
let transferResult;
|
|
34
|
+
// IBC or other bank-module denom (has address, not a contract)
|
|
35
|
+
if ((token === null || token === void 0 ? void 0 : token.address) && !buildCw20TransferMsg.CW20_CONTRACT_ADDRESS_REGEX.test(token.address)) {
|
|
36
|
+
transferResult = buildBankSendMsg.buildBankSendMsg(fromAddress, toAddress, amount, token.address, (_d = token.decimals) !== null && _d !== void 0 ? _d : buildBankSendMsg.DEFAULT_DECIMALS);
|
|
37
|
+
}
|
|
38
|
+
else if (token === null || token === void 0 ? void 0 : token.address) {
|
|
39
|
+
// CW20 contract transfer
|
|
40
|
+
transferResult = buildCw20TransferMsg.buildCw20TransferMsg(fromAddress, toAddress, amount, token.address, (_e = token.decimals) !== null && _e !== void 0 ? _e : buildBankSendMsg.DEFAULT_DECIMALS);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Native token
|
|
44
|
+
transferResult = buildBankSendMsg.buildBankSendMsg(fromAddress, toAddress, amount, nativeDenom, nativeDecimals);
|
|
45
|
+
}
|
|
46
|
+
const { msg, gas } = transferResult;
|
|
47
|
+
// Fee paid in native denom; gas comes from the message builder
|
|
48
|
+
const fee = {
|
|
49
|
+
amount: [{ amount: DEFAULT_FEE_AMOUNT, denom: nativeDenom }],
|
|
50
|
+
gas,
|
|
51
|
+
};
|
|
52
|
+
const stdSignDoc = {
|
|
53
|
+
account_number: accountNumber,
|
|
54
|
+
chain_id: chainId,
|
|
55
|
+
fee,
|
|
56
|
+
memo: '',
|
|
57
|
+
msgs: [msg],
|
|
58
|
+
sequence,
|
|
59
|
+
};
|
|
60
|
+
const provider = yield this.getProvider();
|
|
61
|
+
const { signature } = yield provider.signAmino(chainId, fromAddress, stdSignDoc);
|
|
62
|
+
return broadcastAminoTx.broadcastAminoTx(lcdUrl, stdSignDoc, signature);
|
|
14
63
|
});
|
|
15
64
|
}
|
|
16
65
|
getProvider() {
|
|
@@ -2,9 +2,13 @@ import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
|
2
2
|
import { CosmosWalletConnector } from '../connectors';
|
|
3
3
|
import { ICosmosOfflineSigner, ICosmosProvider } from '../types';
|
|
4
4
|
export declare class CosmosWallet extends Wallet<CosmosWalletConnector> {
|
|
5
|
-
sendBalance({ amount, toAddress, }: {
|
|
5
|
+
sendBalance({ amount, toAddress, token, }: {
|
|
6
6
|
amount: string;
|
|
7
7
|
toAddress: string;
|
|
8
|
+
token?: {
|
|
9
|
+
address: string;
|
|
10
|
+
decimals?: number;
|
|
11
|
+
};
|
|
8
12
|
}): Promise<string | undefined>;
|
|
9
13
|
getProvider(): Promise<ICosmosProvider>;
|
|
10
14
|
getOfflineSigner(): Promise<ICosmosOfflineSigner>;
|
|
@@ -2,11 +2,60 @@
|
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { Wallet, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { cloneObjectWithOverrides } from '@dynamic-labs/utils';
|
|
5
|
+
import { broadcastAminoTx } from './cosmosTransfer/broadcastAminoTx.js';
|
|
6
|
+
import { DEFAULT_DECIMALS, buildBankSendMsg } from './cosmosTransfer/buildBankSendMsg.js';
|
|
7
|
+
import { CW20_CONTRACT_ADDRESS_REGEX, buildCw20TransferMsg } from './cosmosTransfer/buildCw20TransferMsg.js';
|
|
8
|
+
import { fetchAccountSequence } from './cosmosTransfer/fetchAccountSequence.js';
|
|
5
9
|
|
|
10
|
+
const DEFAULT_FEE_AMOUNT = '5000';
|
|
6
11
|
class CosmosWallet extends Wallet {
|
|
7
12
|
sendBalance(_a) {
|
|
8
|
-
return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
9
|
-
|
|
13
|
+
return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, token, }) {
|
|
14
|
+
var _b, _c, _d, _e;
|
|
15
|
+
yield this._connector.connect();
|
|
16
|
+
const chainId = this._connector.getChainId();
|
|
17
|
+
const lcdUrl = this._connector.getLcdUrl();
|
|
18
|
+
const nativeDenom = this._connector.getDenom();
|
|
19
|
+
const fromAddress = this.address;
|
|
20
|
+
if (!lcdUrl) {
|
|
21
|
+
throw new Error('No LCD URL configured for this chain');
|
|
22
|
+
}
|
|
23
|
+
if (!nativeDenom) {
|
|
24
|
+
throw new Error('No native denom configured for this chain');
|
|
25
|
+
}
|
|
26
|
+
const { accountNumber, sequence } = yield fetchAccountSequence(lcdUrl, fromAddress);
|
|
27
|
+
const selectedChain = this._connector.getSelectedChain();
|
|
28
|
+
const nativeDecimals = (_c = (_b = selectedChain === null || selectedChain === void 0 ? void 0 : selectedChain.nativeCurrency) === null || _b === void 0 ? void 0 : _b.decimals) !== null && _c !== void 0 ? _c : DEFAULT_DECIMALS;
|
|
29
|
+
let transferResult;
|
|
30
|
+
// IBC or other bank-module denom (has address, not a contract)
|
|
31
|
+
if ((token === null || token === void 0 ? void 0 : token.address) && !CW20_CONTRACT_ADDRESS_REGEX.test(token.address)) {
|
|
32
|
+
transferResult = buildBankSendMsg(fromAddress, toAddress, amount, token.address, (_d = token.decimals) !== null && _d !== void 0 ? _d : DEFAULT_DECIMALS);
|
|
33
|
+
}
|
|
34
|
+
else if (token === null || token === void 0 ? void 0 : token.address) {
|
|
35
|
+
// CW20 contract transfer
|
|
36
|
+
transferResult = buildCw20TransferMsg(fromAddress, toAddress, amount, token.address, (_e = token.decimals) !== null && _e !== void 0 ? _e : DEFAULT_DECIMALS);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Native token
|
|
40
|
+
transferResult = buildBankSendMsg(fromAddress, toAddress, amount, nativeDenom, nativeDecimals);
|
|
41
|
+
}
|
|
42
|
+
const { msg, gas } = transferResult;
|
|
43
|
+
// Fee paid in native denom; gas comes from the message builder
|
|
44
|
+
const fee = {
|
|
45
|
+
amount: [{ amount: DEFAULT_FEE_AMOUNT, denom: nativeDenom }],
|
|
46
|
+
gas,
|
|
47
|
+
};
|
|
48
|
+
const stdSignDoc = {
|
|
49
|
+
account_number: accountNumber,
|
|
50
|
+
chain_id: chainId,
|
|
51
|
+
fee,
|
|
52
|
+
memo: '',
|
|
53
|
+
msgs: [msg],
|
|
54
|
+
sequence,
|
|
55
|
+
};
|
|
56
|
+
const provider = yield this.getProvider();
|
|
57
|
+
const { signature } = yield provider.signAmino(chainId, fromAddress, stdSignDoc);
|
|
58
|
+
return broadcastAminoTx(lcdUrl, stdSignDoc, signature);
|
|
10
59
|
});
|
|
11
60
|
}
|
|
12
61
|
getProvider() {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const broadcastAminoTx = (lcdUrl, signDoc, signature) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
const response = yield fetch(`${lcdUrl}/txs`, {
|
|
10
|
+
body: JSON.stringify({
|
|
11
|
+
mode: 'sync',
|
|
12
|
+
tx: {
|
|
13
|
+
fee: signDoc.fee,
|
|
14
|
+
memo: signDoc.memo,
|
|
15
|
+
msg: signDoc.msgs,
|
|
16
|
+
signatures: [signature],
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
headers: { 'Content-Type': 'application/json' },
|
|
20
|
+
method: 'POST',
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
throw new Error('Failed to broadcast transaction');
|
|
24
|
+
}
|
|
25
|
+
const result = yield response.json();
|
|
26
|
+
// Non-zero code means the tx was accepted but execution failed
|
|
27
|
+
if (result.code) {
|
|
28
|
+
throw new Error(`Transaction failed: ${result.raw_log}`);
|
|
29
|
+
}
|
|
30
|
+
return result.txhash;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
exports.broadcastAminoTx = broadcastAminoTx;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const broadcastAminoTx = (lcdUrl, signDoc, signature) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
const response = yield fetch(`${lcdUrl}/txs`, {
|
|
6
|
+
body: JSON.stringify({
|
|
7
|
+
mode: 'sync',
|
|
8
|
+
tx: {
|
|
9
|
+
fee: signDoc.fee,
|
|
10
|
+
memo: signDoc.memo,
|
|
11
|
+
msg: signDoc.msgs,
|
|
12
|
+
signatures: [signature],
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
headers: { 'Content-Type': 'application/json' },
|
|
16
|
+
method: 'POST',
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error('Failed to broadcast transaction');
|
|
20
|
+
}
|
|
21
|
+
const result = yield response.json();
|
|
22
|
+
// Non-zero code means the tx was accepted but execution failed
|
|
23
|
+
if (result.code) {
|
|
24
|
+
throw new Error(`Transaction failed: ${result.raw_log}`);
|
|
25
|
+
}
|
|
26
|
+
return result.txhash;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { broadcastAminoTx };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const DEFAULT_DECIMALS = 6;
|
|
7
|
+
const NATIVE_SEND_GAS = '100000';
|
|
8
|
+
const buildBankSendMsg = (fromAddress, toAddress, amount, denom, decimals) => {
|
|
9
|
+
const microAmount = Math.floor(parseFloat(amount) * Math.pow(10, decimals)).toString();
|
|
10
|
+
return {
|
|
11
|
+
gas: NATIVE_SEND_GAS,
|
|
12
|
+
msg: {
|
|
13
|
+
type: 'cosmos-sdk/MsgSend',
|
|
14
|
+
value: {
|
|
15
|
+
amount: [{ amount: microAmount, denom }],
|
|
16
|
+
from_address: fromAddress,
|
|
17
|
+
to_address: toAddress,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.DEFAULT_DECIMALS = DEFAULT_DECIMALS;
|
|
24
|
+
exports.buildBankSendMsg = buildBankSendMsg;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Msg } from '@keplr-wallet/types';
|
|
2
|
+
export declare const DEFAULT_DECIMALS = 6;
|
|
3
|
+
export type TransferMsgResult = {
|
|
4
|
+
gas: string;
|
|
5
|
+
msg: Msg;
|
|
6
|
+
};
|
|
7
|
+
export declare const buildBankSendMsg: (fromAddress: string, toAddress: string, amount: string, denom: string, decimals: number) => TransferMsgResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const DEFAULT_DECIMALS = 6;
|
|
3
|
+
const NATIVE_SEND_GAS = '100000';
|
|
4
|
+
const buildBankSendMsg = (fromAddress, toAddress, amount, denom, decimals) => {
|
|
5
|
+
const microAmount = Math.floor(parseFloat(amount) * Math.pow(10, decimals)).toString();
|
|
6
|
+
return {
|
|
7
|
+
gas: NATIVE_SEND_GAS,
|
|
8
|
+
msg: {
|
|
9
|
+
type: 'cosmos-sdk/MsgSend',
|
|
10
|
+
value: {
|
|
11
|
+
amount: [{ amount: microAmount, denom }],
|
|
12
|
+
from_address: fromAddress,
|
|
13
|
+
to_address: toAddress,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { DEFAULT_DECIMALS, buildBankSendMsg };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
// Matches bech32 contract addresses (prefix + "1" + 30+ alphanumeric chars)
|
|
7
|
+
const CW20_CONTRACT_ADDRESS_REGEX = /^[a-z]+1[a-z0-9]{30,}$/;
|
|
8
|
+
const CW20_SEND_GAS = '200000';
|
|
9
|
+
const buildCw20TransferMsg = (fromAddress, toAddress, amount, contractAddress, decimals) => {
|
|
10
|
+
const baseAmount = Math.floor(parseFloat(amount) * Math.pow(10, decimals)).toString();
|
|
11
|
+
return {
|
|
12
|
+
gas: CW20_SEND_GAS,
|
|
13
|
+
msg: {
|
|
14
|
+
type: 'wasm/MsgExecuteContract',
|
|
15
|
+
value: {
|
|
16
|
+
contract: contractAddress,
|
|
17
|
+
funds: [],
|
|
18
|
+
msg: { transfer: { amount: baseAmount, recipient: toAddress } },
|
|
19
|
+
sender: fromAddress,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.CW20_CONTRACT_ADDRESS_REGEX = CW20_CONTRACT_ADDRESS_REGEX;
|
|
26
|
+
exports.buildCw20TransferMsg = buildCw20TransferMsg;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TransferMsgResult } from './buildBankSendMsg';
|
|
2
|
+
export declare const CW20_CONTRACT_ADDRESS_REGEX: RegExp;
|
|
3
|
+
export declare const buildCw20TransferMsg: (fromAddress: string, toAddress: string, amount: string, contractAddress: string, decimals: number) => TransferMsgResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
// Matches bech32 contract addresses (prefix + "1" + 30+ alphanumeric chars)
|
|
3
|
+
const CW20_CONTRACT_ADDRESS_REGEX = /^[a-z]+1[a-z0-9]{30,}$/;
|
|
4
|
+
const CW20_SEND_GAS = '200000';
|
|
5
|
+
const buildCw20TransferMsg = (fromAddress, toAddress, amount, contractAddress, decimals) => {
|
|
6
|
+
const baseAmount = Math.floor(parseFloat(amount) * Math.pow(10, decimals)).toString();
|
|
7
|
+
return {
|
|
8
|
+
gas: CW20_SEND_GAS,
|
|
9
|
+
msg: {
|
|
10
|
+
type: 'wasm/MsgExecuteContract',
|
|
11
|
+
value: {
|
|
12
|
+
contract: contractAddress,
|
|
13
|
+
funds: [],
|
|
14
|
+
msg: { transfer: { amount: baseAmount, recipient: toAddress } },
|
|
15
|
+
sender: fromAddress,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { CW20_CONTRACT_ADDRESS_REGEX, buildCw20TransferMsg };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const fetchAccountSequence = (lcdUrl, address) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
const response = yield fetch(`${lcdUrl}/cosmos/auth/v1beta1/accounts/${address}`);
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error('Failed to fetch account info');
|
|
13
|
+
}
|
|
14
|
+
const data = yield response.json();
|
|
15
|
+
// Vesting accounts nest the base account one level deeper
|
|
16
|
+
const baseAccount = (_b = (_a = data.account.base_vesting_account) === null || _a === void 0 ? void 0 : _a.base_account) !== null && _b !== void 0 ? _b : data.account;
|
|
17
|
+
return {
|
|
18
|
+
accountNumber: ((_c = baseAccount.account_number) !== null && _c !== void 0 ? _c : '0').toString(),
|
|
19
|
+
sequence: ((_d = baseAccount.sequence) !== null && _d !== void 0 ? _d : '0').toString(),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.fetchAccountSequence = fetchAccountSequence;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const fetchAccountSequence = (lcdUrl, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
const response = yield fetch(`${lcdUrl}/cosmos/auth/v1beta1/accounts/${address}`);
|
|
7
|
+
if (!response.ok) {
|
|
8
|
+
throw new Error('Failed to fetch account info');
|
|
9
|
+
}
|
|
10
|
+
const data = yield response.json();
|
|
11
|
+
// Vesting accounts nest the base account one level deeper
|
|
12
|
+
const baseAccount = (_b = (_a = data.account.base_vesting_account) === null || _a === void 0 ? void 0 : _a.base_account) !== null && _b !== void 0 ? _b : data.account;
|
|
13
|
+
return {
|
|
14
|
+
accountNumber: ((_c = baseAccount.account_number) !== null && _c !== void 0 ? _c : '0').toString(),
|
|
15
|
+
sequence: ((_d = baseAccount.sequence) !== null && _d !== void 0 ? _d : '0').toString(),
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { fetchAccountSequence };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { broadcastAminoTx } from './broadcastAminoTx';
|
|
2
|
+
export { buildBankSendMsg, DEFAULT_DECIMALS } from './buildBankSendMsg';
|
|
3
|
+
export type { TransferMsgResult } from './buildBankSendMsg';
|
|
4
|
+
export { buildCw20TransferMsg, CW20_CONTRACT_ADDRESS_REGEX, } from './buildCw20TransferMsg';
|
|
5
|
+
export { fetchAccountSequence } from './fetchAccountSequence';
|
|
6
|
+
export type { AccountSequenceInfo } from './fetchAccountSequence';
|