@sodax/wallet-sdk-core 2.0.0-rc.12 → 2.0.0-rc.14
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/index.cjs +211 -3
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +212 -4
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -9,6 +9,9 @@ var transactions = require('@mysten/sui/transactions');
|
|
|
9
9
|
var walletStandard = require('@mysten/wallet-standard');
|
|
10
10
|
var IconSdkRaw = require('icon-sdk-js');
|
|
11
11
|
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
12
|
+
var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
|
|
13
|
+
var tx_js$1 = require('cosmjs-types/cosmwasm/wasm/v1/tx.js');
|
|
14
|
+
var networks = require('@injectivelabs/networks');
|
|
12
15
|
var splToken = require('@solana/spl-token');
|
|
13
16
|
var web3_js = require('@solana/web3.js');
|
|
14
17
|
var stellarSdk = require('@stellar/stellar-sdk');
|
|
@@ -367,6 +370,44 @@ var SodaTokens = {
|
|
|
367
370
|
chainKey: ChainKeys.SONIC_MAINNET,
|
|
368
371
|
hubAsset: "0x243b0c26c8b38793908d7C64e8510f21B19B4613",
|
|
369
372
|
vault: "0x243b0c26c8b38793908d7C64e8510f21B19B4613"
|
|
373
|
+
},
|
|
374
|
+
sodaJITOSOL: {
|
|
375
|
+
symbol: "sodaJITOSOL",
|
|
376
|
+
name: "Soda JITOSOL",
|
|
377
|
+
decimals: 18,
|
|
378
|
+
address: "0xe1bad4400d947Bc4fa66f9c0A143D800002083a0",
|
|
379
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
380
|
+
hubAsset: "0xe1bad4400d947Bc4fa66f9c0A143D800002083a0",
|
|
381
|
+
vault: "0xe1bad4400d947Bc4fa66f9c0A143D800002083a0"
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
var LsodaTokens = {
|
|
385
|
+
lsodaWEETH: {
|
|
386
|
+
symbol: "lsodaWEETH",
|
|
387
|
+
name: "Leveraged Soda weETH",
|
|
388
|
+
decimals: 18,
|
|
389
|
+
address: "0xD09de2f5070699A909c0FD32fb5A909d3886701D",
|
|
390
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
391
|
+
hubAsset: "0xD09de2f5070699A909c0FD32fb5A909d3886701D",
|
|
392
|
+
vault: "0xD09de2f5070699A909c0FD32fb5A909d3886701D"
|
|
393
|
+
},
|
|
394
|
+
lsodaWSTETH: {
|
|
395
|
+
symbol: "lsodaWSTETH",
|
|
396
|
+
name: "Leveraged Soda wstETH",
|
|
397
|
+
decimals: 18,
|
|
398
|
+
address: "0x136E5D1CEC5db1829E24941Eddd9C8640E02Ce7a",
|
|
399
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
400
|
+
hubAsset: "0x136E5D1CEC5db1829E24941Eddd9C8640E02Ce7a",
|
|
401
|
+
vault: "0x136E5D1CEC5db1829E24941Eddd9C8640E02Ce7a"
|
|
402
|
+
},
|
|
403
|
+
lsodaJITOSOL: {
|
|
404
|
+
symbol: "lsodaJITOSOL",
|
|
405
|
+
name: "Leveraged Soda JITOSOL",
|
|
406
|
+
decimals: 18,
|
|
407
|
+
address: "0xD7Ae4853E0f93682F5DaA14734F5D18cBa09Bd78",
|
|
408
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
409
|
+
hubAsset: "0xD7Ae4853E0f93682F5DaA14734F5D18cBa09Bd78",
|
|
410
|
+
vault: "0xD7Ae4853E0f93682F5DaA14734F5D18cBa09Bd78"
|
|
370
411
|
}
|
|
371
412
|
};
|
|
372
413
|
var sonicSupportedTokens = {
|
|
@@ -433,7 +474,8 @@ var sonicSupportedTokens = {
|
|
|
433
474
|
hubAsset: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
|
|
434
475
|
vault: SodaTokens.sodaSODA.address
|
|
435
476
|
},
|
|
436
|
-
...SodaTokens
|
|
477
|
+
...SodaTokens,
|
|
478
|
+
...LsodaTokens
|
|
437
479
|
};
|
|
438
480
|
var redbellySupportedTokens = {
|
|
439
481
|
RBNT: {
|
|
@@ -643,7 +685,7 @@ var solanaSupportedTokens = {
|
|
|
643
685
|
address: "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
|
|
644
686
|
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
645
687
|
hubAsset: "0x942f89a324d2652e447b9fcf08effc9f9776a680",
|
|
646
|
-
vault:
|
|
688
|
+
vault: SodaTokens.sodaJITOSOL.address
|
|
647
689
|
},
|
|
648
690
|
mSOL: {
|
|
649
691
|
symbol: "mSOL",
|
|
@@ -1076,6 +1118,15 @@ var baseSupportedTokens = {
|
|
|
1076
1118
|
chainKey: ChainKeys.BASE_MAINNET,
|
|
1077
1119
|
hubAsset: "0xaa81bb5ba3c972ab53605d3ba7e443a3de6d1cb9",
|
|
1078
1120
|
vault: "0xaa81bb5ba3c972ab53605d3ba7e443a3de6d1cb9"
|
|
1121
|
+
},
|
|
1122
|
+
AERO: {
|
|
1123
|
+
symbol: "AERO",
|
|
1124
|
+
name: "Aerodrome Finance",
|
|
1125
|
+
decimals: 18,
|
|
1126
|
+
address: "0x940181a94A35A4569e4529A3CDfB74e38FD98631",
|
|
1127
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
1128
|
+
hubAsset: "0x348e086ab6f424dfc575a325c28624ed23973173",
|
|
1129
|
+
vault: "0x348e086ab6f424dfc575a325c28624ed23973173"
|
|
1079
1130
|
}
|
|
1080
1131
|
};
|
|
1081
1132
|
var optimismSupportedTokens = {
|
|
@@ -1758,6 +1809,33 @@ var stellarSupportedTokens = {
|
|
|
1758
1809
|
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1759
1810
|
hubAsset: "0xD749B5FfFED7cEDaa3239abDd16D677179C29AEc",
|
|
1760
1811
|
vault: SodaTokens.sodaSODA.address
|
|
1812
|
+
},
|
|
1813
|
+
sodaETH: {
|
|
1814
|
+
symbol: "sodaETH",
|
|
1815
|
+
name: "Soda ETH",
|
|
1816
|
+
decimals: 7,
|
|
1817
|
+
address: "CDK5EWVTZLGSLI6D5OSES7XUKWZUKBXDRNOWUVDNPP5RJRP5EYWCW7SL",
|
|
1818
|
+
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1819
|
+
hubAsset: "0x4985a4b72ac723723e9ae82382d12d77e9a715de",
|
|
1820
|
+
vault: SodaTokens.sodaETH.address
|
|
1821
|
+
},
|
|
1822
|
+
sodaBTC: {
|
|
1823
|
+
symbol: "sodaBTC",
|
|
1824
|
+
name: "Soda BTC",
|
|
1825
|
+
decimals: 7,
|
|
1826
|
+
address: "CD6XWBW74YVFDQQYUM2GALCULMA5MAWGP6NTCWF3ZYXP4Z7MEVY4JKBX",
|
|
1827
|
+
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1828
|
+
hubAsset: "0xddee01f63c18843e2bac30cb702864d7632c83a2",
|
|
1829
|
+
vault: SodaTokens.sodaBTC.address
|
|
1830
|
+
},
|
|
1831
|
+
sodaBNB: {
|
|
1832
|
+
symbol: "sodaBNB",
|
|
1833
|
+
name: "Soda BNB",
|
|
1834
|
+
decimals: 7,
|
|
1835
|
+
address: "CCXTXZAFLVNTMORVWYB6BGL7YEW3U3ONDAL2FGBRGDUQH7AGANVQPRS6",
|
|
1836
|
+
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1837
|
+
hubAsset: "0xa10be5f5c2dea7d272555dc73ea2a7317c3c5b63",
|
|
1838
|
+
vault: SodaTokens.sodaBNB.address
|
|
1761
1839
|
}
|
|
1762
1840
|
};
|
|
1763
1841
|
var suiSupportedTokens = {
|
|
@@ -2874,6 +2952,21 @@ var spokeChainConfig = {
|
|
|
2874
2952
|
assetCode: "SODA",
|
|
2875
2953
|
contractId: "CAH5LKJC2ZB4RVUVEVL2QWJWNJLHQE2UF767ILLQ5EQ4O3OURR2XIUGM",
|
|
2876
2954
|
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
assetCode: "sodaETH",
|
|
2958
|
+
contractId: "CDK5EWVTZLGSLI6D5OSES7XUKWZUKBXDRNOWUVDNPP5RJRP5EYWCW7SL",
|
|
2959
|
+
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2960
|
+
},
|
|
2961
|
+
{
|
|
2962
|
+
assetCode: "sodaBTC",
|
|
2963
|
+
contractId: "CD6XWBW74YVFDQQYUM2GALCULMA5MAWGP6NTCWF3ZYXP4Z7MEVY4JKBX",
|
|
2964
|
+
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2965
|
+
},
|
|
2966
|
+
{
|
|
2967
|
+
assetCode: "sodaBNB",
|
|
2968
|
+
contractId: "CCXTXZAFLVNTMORVWYB6BGL7YEW3U3ONDAL2FGBRGDUQH7AGANVQPRS6",
|
|
2969
|
+
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2877
2970
|
}
|
|
2878
2971
|
],
|
|
2879
2972
|
supportedTokens: stellarSupportedTokens,
|
|
@@ -3020,9 +3113,57 @@ var hubConfig = {
|
|
|
3020
3113
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.USDT,
|
|
3021
3114
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.wS,
|
|
3022
3115
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.SODA,
|
|
3023
|
-
|
|
3116
|
+
// sodaUSDS is staging-only — see stagingSwapSupportedTokens
|
|
3117
|
+
...Object.values(SodaTokens).filter((t) => t !== SodaTokens.sodaUSDS),
|
|
3118
|
+
...Object.values(LsodaTokens)
|
|
3024
3119
|
]});
|
|
3025
3120
|
|
|
3121
|
+
// ../types/dist/leverageYield/leverageYield.js
|
|
3122
|
+
[
|
|
3123
|
+
{
|
|
3124
|
+
name: LsodaTokens.lsodaWEETH.symbol,
|
|
3125
|
+
vault: LsodaTokens.lsodaWEETH.vault,
|
|
3126
|
+
asset: SodaTokens.sodaWEETH.address,
|
|
3127
|
+
// sodaWEETH on Sonic
|
|
3128
|
+
borrowToken: SodaTokens.sodaETH.address,
|
|
3129
|
+
// sodaETH on Sonic
|
|
3130
|
+
lsdSource: {
|
|
3131
|
+
// DefiLlama pool for EtherFi's weETH on Ethereum (project: 'ether.fi-stake').
|
|
3132
|
+
poolId: "46bd2bdf-6d92-4066-b482-e885ee172264",
|
|
3133
|
+
fallbackAprPct: 3,
|
|
3134
|
+
label: "EtherFi (weETH)"
|
|
3135
|
+
}
|
|
3136
|
+
},
|
|
3137
|
+
{
|
|
3138
|
+
name: LsodaTokens.lsodaWSTETH.symbol,
|
|
3139
|
+
vault: LsodaTokens.lsodaWSTETH.vault,
|
|
3140
|
+
asset: SodaTokens.sodaWSTETH.address,
|
|
3141
|
+
// sodaWSTETH on Sonic
|
|
3142
|
+
borrowToken: SodaTokens.sodaETH.address,
|
|
3143
|
+
// sodaETH on Sonic
|
|
3144
|
+
lsdSource: {
|
|
3145
|
+
// DefiLlama pool for Lido's stETH on Ethereum (wstETH inherits this rate via redeem).
|
|
3146
|
+
poolId: "747c1d2a-c668-4682-b9f9-296708a3dd90",
|
|
3147
|
+
fallbackAprPct: 2.4,
|
|
3148
|
+
label: "Lido (stETH)"
|
|
3149
|
+
}
|
|
3150
|
+
},
|
|
3151
|
+
{
|
|
3152
|
+
name: LsodaTokens.lsodaJITOSOL.symbol,
|
|
3153
|
+
vault: LsodaTokens.lsodaJITOSOL.vault,
|
|
3154
|
+
asset: SodaTokens.sodaJITOSOL.address,
|
|
3155
|
+
// sodaJITOSOL on Sonic
|
|
3156
|
+
borrowToken: SodaTokens.sodaSOL.address,
|
|
3157
|
+
// sodaSOL on Sonic
|
|
3158
|
+
lsdSource: {
|
|
3159
|
+
// DefiLlama pool for Jito's JitoSOL native staking on Solana (project: 'jito-liquid-staking').
|
|
3160
|
+
poolId: "0e7d0722-9054-4907-8593-567b353c0900",
|
|
3161
|
+
fallbackAprPct: 5.5,
|
|
3162
|
+
label: "Jito (JitoSOL)"
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
];
|
|
3166
|
+
|
|
3026
3167
|
// ../types/dist/bitcoin/bitcoin.js
|
|
3027
3168
|
function detectBitcoinAddressType(address) {
|
|
3028
3169
|
if (address.startsWith("bc1p") || address.startsWith("tb1p"))
|
|
@@ -3451,13 +3592,32 @@ function txResponseToExecuteResponse(txResult) {
|
|
|
3451
3592
|
transactionHash: txResult.txHash
|
|
3452
3593
|
};
|
|
3453
3594
|
}
|
|
3595
|
+
var COSMWASM_MSG_EXECUTE_CONTRACT_TYPE_URL = "/cosmwasm.wasm.v1.MsgExecuteContract";
|
|
3596
|
+
function decodeInjectiveExecuteMsgs(bodyBytes) {
|
|
3597
|
+
const { messages } = tx_js.TxBody.decode(bodyBytes);
|
|
3598
|
+
return messages.map((message) => {
|
|
3599
|
+
if (message.typeUrl !== COSMWASM_MSG_EXECUTE_CONTRACT_TYPE_URL) {
|
|
3600
|
+
throw new Error(`Injective: cannot rebuild message type ${message.typeUrl} for browser signing.`);
|
|
3601
|
+
}
|
|
3602
|
+
const { sender, contract, msg, funds } = tx_js$1.MsgExecuteContract.decode(message.value);
|
|
3603
|
+
return sdkTs.MsgExecuteContractCompat.fromJSON({
|
|
3604
|
+
contractAddress: contract,
|
|
3605
|
+
sender,
|
|
3606
|
+
msg: JSON.parse(Buffer.from(msg).toString("utf8")),
|
|
3607
|
+
funds: funds.map((coin) => ({ denom: coin.denom, amount: coin.amount }))
|
|
3608
|
+
});
|
|
3609
|
+
});
|
|
3610
|
+
}
|
|
3454
3611
|
var InjectiveWalletProvider = class extends BaseWalletProvider {
|
|
3455
3612
|
chainType = "INJECTIVE";
|
|
3456
3613
|
wallet;
|
|
3614
|
+
/** Network endpoints used to broadcast a signed `TxRaw` via {@link sendTransaction}. */
|
|
3615
|
+
endpoints;
|
|
3457
3616
|
constructor(config) {
|
|
3458
3617
|
super(config.defaults);
|
|
3459
3618
|
if (isBrowserExtensionInjectiveWalletConfig(config)) {
|
|
3460
3619
|
this.wallet = { msgBroadcaster: config.msgBroadcaster };
|
|
3620
|
+
this.endpoints = config.msgBroadcaster.endpoints;
|
|
3461
3621
|
return;
|
|
3462
3622
|
}
|
|
3463
3623
|
if (isSecretInjectiveWalletConfig(config)) {
|
|
@@ -3470,6 +3630,7 @@ var InjectiveWalletProvider = class extends BaseWalletProvider {
|
|
|
3470
3630
|
throw new Error("Invalid Secret Injective wallet config");
|
|
3471
3631
|
}
|
|
3472
3632
|
this.wallet = { msgBroadcaster: new sdkTs.MsgBroadcasterWithPk({ privateKey, network: config.network }) };
|
|
3633
|
+
this.endpoints = networks.getNetworkEndpoints(config.network);
|
|
3473
3634
|
return;
|
|
3474
3635
|
}
|
|
3475
3636
|
throw new Error("Invalid Injective wallet config");
|
|
@@ -3562,6 +3723,53 @@ var InjectiveWalletProvider = class extends BaseWalletProvider {
|
|
|
3562
3723
|
}
|
|
3563
3724
|
return txResponseToExecuteResponse(txResult);
|
|
3564
3725
|
}
|
|
3726
|
+
/**
|
|
3727
|
+
* Broadcasts an already-signed, proto-encoded Cosmos `TxRaw` via the configured gRPC endpoint.
|
|
3728
|
+
* @param signedTxRaw - The signed transaction, encoded with `TxRaw.encode(...).finish()`.
|
|
3729
|
+
* @returns The transaction hash.
|
|
3730
|
+
* @throws {Error} if the node rejects the transaction (non-zero result code).
|
|
3731
|
+
*/
|
|
3732
|
+
async sendTransaction(signedTxRaw) {
|
|
3733
|
+
const txRaw = tx_js.TxRaw.decode(signedTxRaw);
|
|
3734
|
+
const res = await new sdkTs.TxGrpcApi(this.endpoints.grpc).broadcast(txRaw);
|
|
3735
|
+
if (res.code !== 0) {
|
|
3736
|
+
throw new Error(`Injective broadcast failed (code ${res.code}): ${res.rawLog}`);
|
|
3737
|
+
}
|
|
3738
|
+
return res.txHash;
|
|
3739
|
+
}
|
|
3740
|
+
/**
|
|
3741
|
+
* Signs and broadcasts an unsigned `InjectiveRawTransaction` (e.g. from the Swaps API).
|
|
3742
|
+
*
|
|
3743
|
+
* - **PK (secret) mode**: signs the exact unsigned `SignDoc` (`bodyBytes`/`authInfoBytes`) and
|
|
3744
|
+
* broadcasts it as-is, preserving the precise fee/account the Swaps API built.
|
|
3745
|
+
* - **Browser mode (Keplr/Leap/Metamask)**: an EVM wallet can't sign a raw Cosmos `SignDoc`, so we
|
|
3746
|
+
* recover the messages from `bodyBytes` and broadcast them through the fee-delegation path (same as
|
|
3747
|
+
* {@link execute}). The broadcaster builds the wallet-appropriate sign payload (DIRECT for Cosmos
|
|
3748
|
+
* wallets, EIP-712 for Metamask). Trade-off: the broadcaster recomputes gas/fee rather than using
|
|
3749
|
+
* the exact fee in the raw tx; the on-chain effect (the execute message) is unchanged.
|
|
3750
|
+
*
|
|
3751
|
+
* @returns The transaction hash.
|
|
3752
|
+
*/
|
|
3753
|
+
async signAndSendTransaction(tx) {
|
|
3754
|
+
const { bodyBytes, authInfoBytes, chainId, accountNumber } = tx.signedDoc;
|
|
3755
|
+
const signerAddress = await this.getWalletAddress();
|
|
3756
|
+
if (tx.from !== signerAddress) {
|
|
3757
|
+
throw new Error(`Injective: cannot sign transaction for ${tx.from} with wallet ${signerAddress}.`);
|
|
3758
|
+
}
|
|
3759
|
+
if (this.wallet.msgBroadcaster instanceof sdkTs.MsgBroadcasterWithPk) {
|
|
3760
|
+
const signDoc = tx_js.SignDoc.fromPartial({ bodyBytes, authInfoBytes, chainId, accountNumber });
|
|
3761
|
+
const signBytes = tx_js.SignDoc.encode(signDoc).finish();
|
|
3762
|
+
const signature = this.wallet.msgBroadcaster.privateKey.sign(Buffer.from(signBytes));
|
|
3763
|
+
const signedTxRaw = tx_js.TxRaw.fromPartial({ bodyBytes, authInfoBytes, signatures: [signature] });
|
|
3764
|
+
return this.sendTransaction(tx_js.TxRaw.encode(signedTxRaw).finish());
|
|
3765
|
+
}
|
|
3766
|
+
const msgs = decodeInjectiveExecuteMsgs(bodyBytes);
|
|
3767
|
+
const txResult = await this.wallet.msgBroadcaster.broadcastWithFeeDelegation({
|
|
3768
|
+
msgs,
|
|
3769
|
+
injectiveAddress: signerAddress
|
|
3770
|
+
});
|
|
3771
|
+
return txResult.txHash;
|
|
3772
|
+
}
|
|
3565
3773
|
};
|
|
3566
3774
|
var DEFAULT_CONNECTION_COMMITMENT = "confirmed";
|
|
3567
3775
|
var DEFAULT_CONFIRM_COMMITMENT = "finalized";
|
package/dist/index.d.cts
CHANGED
|
@@ -410,6 +410,8 @@ declare function isSecretInjectiveWalletConfig(config: InjectiveWalletConfig): c
|
|
|
410
410
|
declare class InjectiveWalletProvider extends BaseWalletProvider<InjectiveWalletDefaults> implements IInjectiveWalletProvider {
|
|
411
411
|
readonly chainType: "INJECTIVE";
|
|
412
412
|
wallet: InjectiveWallet;
|
|
413
|
+
/** Network endpoints used to broadcast a signed `TxRaw` via {@link sendTransaction}. */
|
|
414
|
+
private readonly endpoints;
|
|
413
415
|
constructor(config: InjectiveWalletConfig);
|
|
414
416
|
/**
|
|
415
417
|
* Builds a signed-but-unbroadcast Injective transaction for a CosmWasm contract call.
|
|
@@ -428,6 +430,27 @@ declare class InjectiveWalletProvider extends BaseWalletProvider<InjectiveWallet
|
|
|
428
430
|
getWalletAddress(): Promise<InjectiveEoaAddress>;
|
|
429
431
|
getWalletPubKey(): Promise<string>;
|
|
430
432
|
execute(senderAddress: string, contractAddress: string, msg: JsonObject, funds?: InjectiveCoin[], options?: InjectiveWalletDefaults): Promise<InjectiveExecuteResponse>;
|
|
433
|
+
/**
|
|
434
|
+
* Broadcasts an already-signed, proto-encoded Cosmos `TxRaw` via the configured gRPC endpoint.
|
|
435
|
+
* @param signedTxRaw - The signed transaction, encoded with `TxRaw.encode(...).finish()`.
|
|
436
|
+
* @returns The transaction hash.
|
|
437
|
+
* @throws {Error} if the node rejects the transaction (non-zero result code).
|
|
438
|
+
*/
|
|
439
|
+
sendTransaction(signedTxRaw: Uint8Array): Promise<string>;
|
|
440
|
+
/**
|
|
441
|
+
* Signs and broadcasts an unsigned `InjectiveRawTransaction` (e.g. from the Swaps API).
|
|
442
|
+
*
|
|
443
|
+
* - **PK (secret) mode**: signs the exact unsigned `SignDoc` (`bodyBytes`/`authInfoBytes`) and
|
|
444
|
+
* broadcasts it as-is, preserving the precise fee/account the Swaps API built.
|
|
445
|
+
* - **Browser mode (Keplr/Leap/Metamask)**: an EVM wallet can't sign a raw Cosmos `SignDoc`, so we
|
|
446
|
+
* recover the messages from `bodyBytes` and broadcast them through the fee-delegation path (same as
|
|
447
|
+
* {@link execute}). The broadcaster builds the wallet-appropriate sign payload (DIRECT for Cosmos
|
|
448
|
+
* wallets, EIP-712 for Metamask). Trade-off: the broadcaster recomputes gas/fee rather than using
|
|
449
|
+
* the exact fee in the raw tx; the on-chain effect (the execute message) is unchanged.
|
|
450
|
+
*
|
|
451
|
+
* @returns The transaction hash.
|
|
452
|
+
*/
|
|
453
|
+
signAndSendTransaction(tx: InjectiveRawTransaction): Promise<string>;
|
|
431
454
|
}
|
|
432
455
|
|
|
433
456
|
interface WalletContextState {
|
package/dist/index.d.ts
CHANGED
|
@@ -410,6 +410,8 @@ declare function isSecretInjectiveWalletConfig(config: InjectiveWalletConfig): c
|
|
|
410
410
|
declare class InjectiveWalletProvider extends BaseWalletProvider<InjectiveWalletDefaults> implements IInjectiveWalletProvider {
|
|
411
411
|
readonly chainType: "INJECTIVE";
|
|
412
412
|
wallet: InjectiveWallet;
|
|
413
|
+
/** Network endpoints used to broadcast a signed `TxRaw` via {@link sendTransaction}. */
|
|
414
|
+
private readonly endpoints;
|
|
413
415
|
constructor(config: InjectiveWalletConfig);
|
|
414
416
|
/**
|
|
415
417
|
* Builds a signed-but-unbroadcast Injective transaction for a CosmWasm contract call.
|
|
@@ -428,6 +430,27 @@ declare class InjectiveWalletProvider extends BaseWalletProvider<InjectiveWallet
|
|
|
428
430
|
getWalletAddress(): Promise<InjectiveEoaAddress>;
|
|
429
431
|
getWalletPubKey(): Promise<string>;
|
|
430
432
|
execute(senderAddress: string, contractAddress: string, msg: JsonObject, funds?: InjectiveCoin[], options?: InjectiveWalletDefaults): Promise<InjectiveExecuteResponse>;
|
|
433
|
+
/**
|
|
434
|
+
* Broadcasts an already-signed, proto-encoded Cosmos `TxRaw` via the configured gRPC endpoint.
|
|
435
|
+
* @param signedTxRaw - The signed transaction, encoded with `TxRaw.encode(...).finish()`.
|
|
436
|
+
* @returns The transaction hash.
|
|
437
|
+
* @throws {Error} if the node rejects the transaction (non-zero result code).
|
|
438
|
+
*/
|
|
439
|
+
sendTransaction(signedTxRaw: Uint8Array): Promise<string>;
|
|
440
|
+
/**
|
|
441
|
+
* Signs and broadcasts an unsigned `InjectiveRawTransaction` (e.g. from the Swaps API).
|
|
442
|
+
*
|
|
443
|
+
* - **PK (secret) mode**: signs the exact unsigned `SignDoc` (`bodyBytes`/`authInfoBytes`) and
|
|
444
|
+
* broadcasts it as-is, preserving the precise fee/account the Swaps API built.
|
|
445
|
+
* - **Browser mode (Keplr/Leap/Metamask)**: an EVM wallet can't sign a raw Cosmos `SignDoc`, so we
|
|
446
|
+
* recover the messages from `bodyBytes` and broadcast them through the fee-delegation path (same as
|
|
447
|
+
* {@link execute}). The broadcaster builds the wallet-appropriate sign payload (DIRECT for Cosmos
|
|
448
|
+
* wallets, EIP-712 for Metamask). Trade-off: the broadcaster recomputes gas/fee rather than using
|
|
449
|
+
* the exact fee in the raw tx; the on-chain effect (the execute message) is unchanged.
|
|
450
|
+
*
|
|
451
|
+
* @returns The transaction hash.
|
|
452
|
+
*/
|
|
453
|
+
signAndSendTransaction(tx: InjectiveRawTransaction): Promise<string>;
|
|
431
454
|
}
|
|
432
455
|
|
|
433
456
|
interface WalletContextState {
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,10 @@ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
|
6
6
|
import { Transaction as Transaction$1 } from '@mysten/sui/transactions';
|
|
7
7
|
import { signTransaction } from '@mysten/wallet-standard';
|
|
8
8
|
import * as IconSdkRaw from 'icon-sdk-js';
|
|
9
|
-
import { PrivateKey, MsgBroadcasterWithPk, MsgExecuteContract, createTransaction, getInjectiveSignerAddress, MsgExecuteContractCompat } from '@injectivelabs/sdk-ts';
|
|
9
|
+
import { PrivateKey, MsgBroadcasterWithPk, MsgExecuteContract, createTransaction, getInjectiveSignerAddress, MsgExecuteContractCompat, TxGrpcApi } from '@injectivelabs/sdk-ts';
|
|
10
|
+
import { TxRaw, SignDoc, TxBody } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
11
|
+
import { MsgExecuteContract as MsgExecuteContract$1 } from 'cosmjs-types/cosmwasm/wasm/v1/tx.js';
|
|
12
|
+
import { getNetworkEndpoints } from '@injectivelabs/networks';
|
|
10
13
|
import { getAssociatedTokenAddress } from '@solana/spl-token';
|
|
11
14
|
import { Keypair, Connection, TransactionMessage, VersionedTransaction, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
12
15
|
import { Networks, Keypair as Keypair$1, Horizon, Transaction } from '@stellar/stellar-sdk';
|
|
@@ -341,6 +344,44 @@ var SodaTokens = {
|
|
|
341
344
|
chainKey: ChainKeys.SONIC_MAINNET,
|
|
342
345
|
hubAsset: "0x243b0c26c8b38793908d7C64e8510f21B19B4613",
|
|
343
346
|
vault: "0x243b0c26c8b38793908d7C64e8510f21B19B4613"
|
|
347
|
+
},
|
|
348
|
+
sodaJITOSOL: {
|
|
349
|
+
symbol: "sodaJITOSOL",
|
|
350
|
+
name: "Soda JITOSOL",
|
|
351
|
+
decimals: 18,
|
|
352
|
+
address: "0xe1bad4400d947Bc4fa66f9c0A143D800002083a0",
|
|
353
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
354
|
+
hubAsset: "0xe1bad4400d947Bc4fa66f9c0A143D800002083a0",
|
|
355
|
+
vault: "0xe1bad4400d947Bc4fa66f9c0A143D800002083a0"
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var LsodaTokens = {
|
|
359
|
+
lsodaWEETH: {
|
|
360
|
+
symbol: "lsodaWEETH",
|
|
361
|
+
name: "Leveraged Soda weETH",
|
|
362
|
+
decimals: 18,
|
|
363
|
+
address: "0xD09de2f5070699A909c0FD32fb5A909d3886701D",
|
|
364
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
365
|
+
hubAsset: "0xD09de2f5070699A909c0FD32fb5A909d3886701D",
|
|
366
|
+
vault: "0xD09de2f5070699A909c0FD32fb5A909d3886701D"
|
|
367
|
+
},
|
|
368
|
+
lsodaWSTETH: {
|
|
369
|
+
symbol: "lsodaWSTETH",
|
|
370
|
+
name: "Leveraged Soda wstETH",
|
|
371
|
+
decimals: 18,
|
|
372
|
+
address: "0x136E5D1CEC5db1829E24941Eddd9C8640E02Ce7a",
|
|
373
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
374
|
+
hubAsset: "0x136E5D1CEC5db1829E24941Eddd9C8640E02Ce7a",
|
|
375
|
+
vault: "0x136E5D1CEC5db1829E24941Eddd9C8640E02Ce7a"
|
|
376
|
+
},
|
|
377
|
+
lsodaJITOSOL: {
|
|
378
|
+
symbol: "lsodaJITOSOL",
|
|
379
|
+
name: "Leveraged Soda JITOSOL",
|
|
380
|
+
decimals: 18,
|
|
381
|
+
address: "0xD7Ae4853E0f93682F5DaA14734F5D18cBa09Bd78",
|
|
382
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
383
|
+
hubAsset: "0xD7Ae4853E0f93682F5DaA14734F5D18cBa09Bd78",
|
|
384
|
+
vault: "0xD7Ae4853E0f93682F5DaA14734F5D18cBa09Bd78"
|
|
344
385
|
}
|
|
345
386
|
};
|
|
346
387
|
var sonicSupportedTokens = {
|
|
@@ -407,7 +448,8 @@ var sonicSupportedTokens = {
|
|
|
407
448
|
hubAsset: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
|
|
408
449
|
vault: SodaTokens.sodaSODA.address
|
|
409
450
|
},
|
|
410
|
-
...SodaTokens
|
|
451
|
+
...SodaTokens,
|
|
452
|
+
...LsodaTokens
|
|
411
453
|
};
|
|
412
454
|
var redbellySupportedTokens = {
|
|
413
455
|
RBNT: {
|
|
@@ -617,7 +659,7 @@ var solanaSupportedTokens = {
|
|
|
617
659
|
address: "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
|
|
618
660
|
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
619
661
|
hubAsset: "0x942f89a324d2652e447b9fcf08effc9f9776a680",
|
|
620
|
-
vault:
|
|
662
|
+
vault: SodaTokens.sodaJITOSOL.address
|
|
621
663
|
},
|
|
622
664
|
mSOL: {
|
|
623
665
|
symbol: "mSOL",
|
|
@@ -1050,6 +1092,15 @@ var baseSupportedTokens = {
|
|
|
1050
1092
|
chainKey: ChainKeys.BASE_MAINNET,
|
|
1051
1093
|
hubAsset: "0xaa81bb5ba3c972ab53605d3ba7e443a3de6d1cb9",
|
|
1052
1094
|
vault: "0xaa81bb5ba3c972ab53605d3ba7e443a3de6d1cb9"
|
|
1095
|
+
},
|
|
1096
|
+
AERO: {
|
|
1097
|
+
symbol: "AERO",
|
|
1098
|
+
name: "Aerodrome Finance",
|
|
1099
|
+
decimals: 18,
|
|
1100
|
+
address: "0x940181a94A35A4569e4529A3CDfB74e38FD98631",
|
|
1101
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
1102
|
+
hubAsset: "0x348e086ab6f424dfc575a325c28624ed23973173",
|
|
1103
|
+
vault: "0x348e086ab6f424dfc575a325c28624ed23973173"
|
|
1053
1104
|
}
|
|
1054
1105
|
};
|
|
1055
1106
|
var optimismSupportedTokens = {
|
|
@@ -1732,6 +1783,33 @@ var stellarSupportedTokens = {
|
|
|
1732
1783
|
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1733
1784
|
hubAsset: "0xD749B5FfFED7cEDaa3239abDd16D677179C29AEc",
|
|
1734
1785
|
vault: SodaTokens.sodaSODA.address
|
|
1786
|
+
},
|
|
1787
|
+
sodaETH: {
|
|
1788
|
+
symbol: "sodaETH",
|
|
1789
|
+
name: "Soda ETH",
|
|
1790
|
+
decimals: 7,
|
|
1791
|
+
address: "CDK5EWVTZLGSLI6D5OSES7XUKWZUKBXDRNOWUVDNPP5RJRP5EYWCW7SL",
|
|
1792
|
+
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1793
|
+
hubAsset: "0x4985a4b72ac723723e9ae82382d12d77e9a715de",
|
|
1794
|
+
vault: SodaTokens.sodaETH.address
|
|
1795
|
+
},
|
|
1796
|
+
sodaBTC: {
|
|
1797
|
+
symbol: "sodaBTC",
|
|
1798
|
+
name: "Soda BTC",
|
|
1799
|
+
decimals: 7,
|
|
1800
|
+
address: "CD6XWBW74YVFDQQYUM2GALCULMA5MAWGP6NTCWF3ZYXP4Z7MEVY4JKBX",
|
|
1801
|
+
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1802
|
+
hubAsset: "0xddee01f63c18843e2bac30cb702864d7632c83a2",
|
|
1803
|
+
vault: SodaTokens.sodaBTC.address
|
|
1804
|
+
},
|
|
1805
|
+
sodaBNB: {
|
|
1806
|
+
symbol: "sodaBNB",
|
|
1807
|
+
name: "Soda BNB",
|
|
1808
|
+
decimals: 7,
|
|
1809
|
+
address: "CCXTXZAFLVNTMORVWYB6BGL7YEW3U3ONDAL2FGBRGDUQH7AGANVQPRS6",
|
|
1810
|
+
chainKey: ChainKeys.STELLAR_MAINNET,
|
|
1811
|
+
hubAsset: "0xa10be5f5c2dea7d272555dc73ea2a7317c3c5b63",
|
|
1812
|
+
vault: SodaTokens.sodaBNB.address
|
|
1735
1813
|
}
|
|
1736
1814
|
};
|
|
1737
1815
|
var suiSupportedTokens = {
|
|
@@ -2848,6 +2926,21 @@ var spokeChainConfig = {
|
|
|
2848
2926
|
assetCode: "SODA",
|
|
2849
2927
|
contractId: "CAH5LKJC2ZB4RVUVEVL2QWJWNJLHQE2UF767ILLQ5EQ4O3OURR2XIUGM",
|
|
2850
2928
|
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2929
|
+
},
|
|
2930
|
+
{
|
|
2931
|
+
assetCode: "sodaETH",
|
|
2932
|
+
contractId: "CDK5EWVTZLGSLI6D5OSES7XUKWZUKBXDRNOWUVDNPP5RJRP5EYWCW7SL",
|
|
2933
|
+
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2934
|
+
},
|
|
2935
|
+
{
|
|
2936
|
+
assetCode: "sodaBTC",
|
|
2937
|
+
contractId: "CD6XWBW74YVFDQQYUM2GALCULMA5MAWGP6NTCWF3ZYXP4Z7MEVY4JKBX",
|
|
2938
|
+
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
assetCode: "sodaBNB",
|
|
2942
|
+
contractId: "CCXTXZAFLVNTMORVWYB6BGL7YEW3U3ONDAL2FGBRGDUQH7AGANVQPRS6",
|
|
2943
|
+
assetIssuer: "GDYUTHY75A7WUZJQDPOP66FB32BOYGZRXHWTWO4Q6LQTANT5X3V5HNFA"
|
|
2851
2944
|
}
|
|
2852
2945
|
],
|
|
2853
2946
|
supportedTokens: stellarSupportedTokens,
|
|
@@ -2994,9 +3087,57 @@ var hubConfig = {
|
|
|
2994
3087
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.USDT,
|
|
2995
3088
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.wS,
|
|
2996
3089
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.SODA,
|
|
2997
|
-
|
|
3090
|
+
// sodaUSDS is staging-only — see stagingSwapSupportedTokens
|
|
3091
|
+
...Object.values(SodaTokens).filter((t) => t !== SodaTokens.sodaUSDS),
|
|
3092
|
+
...Object.values(LsodaTokens)
|
|
2998
3093
|
]});
|
|
2999
3094
|
|
|
3095
|
+
// ../types/dist/leverageYield/leverageYield.js
|
|
3096
|
+
[
|
|
3097
|
+
{
|
|
3098
|
+
name: LsodaTokens.lsodaWEETH.symbol,
|
|
3099
|
+
vault: LsodaTokens.lsodaWEETH.vault,
|
|
3100
|
+
asset: SodaTokens.sodaWEETH.address,
|
|
3101
|
+
// sodaWEETH on Sonic
|
|
3102
|
+
borrowToken: SodaTokens.sodaETH.address,
|
|
3103
|
+
// sodaETH on Sonic
|
|
3104
|
+
lsdSource: {
|
|
3105
|
+
// DefiLlama pool for EtherFi's weETH on Ethereum (project: 'ether.fi-stake').
|
|
3106
|
+
poolId: "46bd2bdf-6d92-4066-b482-e885ee172264",
|
|
3107
|
+
fallbackAprPct: 3,
|
|
3108
|
+
label: "EtherFi (weETH)"
|
|
3109
|
+
}
|
|
3110
|
+
},
|
|
3111
|
+
{
|
|
3112
|
+
name: LsodaTokens.lsodaWSTETH.symbol,
|
|
3113
|
+
vault: LsodaTokens.lsodaWSTETH.vault,
|
|
3114
|
+
asset: SodaTokens.sodaWSTETH.address,
|
|
3115
|
+
// sodaWSTETH on Sonic
|
|
3116
|
+
borrowToken: SodaTokens.sodaETH.address,
|
|
3117
|
+
// sodaETH on Sonic
|
|
3118
|
+
lsdSource: {
|
|
3119
|
+
// DefiLlama pool for Lido's stETH on Ethereum (wstETH inherits this rate via redeem).
|
|
3120
|
+
poolId: "747c1d2a-c668-4682-b9f9-296708a3dd90",
|
|
3121
|
+
fallbackAprPct: 2.4,
|
|
3122
|
+
label: "Lido (stETH)"
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
{
|
|
3126
|
+
name: LsodaTokens.lsodaJITOSOL.symbol,
|
|
3127
|
+
vault: LsodaTokens.lsodaJITOSOL.vault,
|
|
3128
|
+
asset: SodaTokens.sodaJITOSOL.address,
|
|
3129
|
+
// sodaJITOSOL on Sonic
|
|
3130
|
+
borrowToken: SodaTokens.sodaSOL.address,
|
|
3131
|
+
// sodaSOL on Sonic
|
|
3132
|
+
lsdSource: {
|
|
3133
|
+
// DefiLlama pool for Jito's JitoSOL native staking on Solana (project: 'jito-liquid-staking').
|
|
3134
|
+
poolId: "0e7d0722-9054-4907-8593-567b353c0900",
|
|
3135
|
+
fallbackAprPct: 5.5,
|
|
3136
|
+
label: "Jito (JitoSOL)"
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
];
|
|
3140
|
+
|
|
3000
3141
|
// ../types/dist/bitcoin/bitcoin.js
|
|
3001
3142
|
function detectBitcoinAddressType(address) {
|
|
3002
3143
|
if (address.startsWith("bc1p") || address.startsWith("tb1p"))
|
|
@@ -3425,13 +3566,32 @@ function txResponseToExecuteResponse(txResult) {
|
|
|
3425
3566
|
transactionHash: txResult.txHash
|
|
3426
3567
|
};
|
|
3427
3568
|
}
|
|
3569
|
+
var COSMWASM_MSG_EXECUTE_CONTRACT_TYPE_URL = "/cosmwasm.wasm.v1.MsgExecuteContract";
|
|
3570
|
+
function decodeInjectiveExecuteMsgs(bodyBytes) {
|
|
3571
|
+
const { messages } = TxBody.decode(bodyBytes);
|
|
3572
|
+
return messages.map((message) => {
|
|
3573
|
+
if (message.typeUrl !== COSMWASM_MSG_EXECUTE_CONTRACT_TYPE_URL) {
|
|
3574
|
+
throw new Error(`Injective: cannot rebuild message type ${message.typeUrl} for browser signing.`);
|
|
3575
|
+
}
|
|
3576
|
+
const { sender, contract, msg, funds } = MsgExecuteContract$1.decode(message.value);
|
|
3577
|
+
return MsgExecuteContractCompat.fromJSON({
|
|
3578
|
+
contractAddress: contract,
|
|
3579
|
+
sender,
|
|
3580
|
+
msg: JSON.parse(Buffer.from(msg).toString("utf8")),
|
|
3581
|
+
funds: funds.map((coin) => ({ denom: coin.denom, amount: coin.amount }))
|
|
3582
|
+
});
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3428
3585
|
var InjectiveWalletProvider = class extends BaseWalletProvider {
|
|
3429
3586
|
chainType = "INJECTIVE";
|
|
3430
3587
|
wallet;
|
|
3588
|
+
/** Network endpoints used to broadcast a signed `TxRaw` via {@link sendTransaction}. */
|
|
3589
|
+
endpoints;
|
|
3431
3590
|
constructor(config) {
|
|
3432
3591
|
super(config.defaults);
|
|
3433
3592
|
if (isBrowserExtensionInjectiveWalletConfig(config)) {
|
|
3434
3593
|
this.wallet = { msgBroadcaster: config.msgBroadcaster };
|
|
3594
|
+
this.endpoints = config.msgBroadcaster.endpoints;
|
|
3435
3595
|
return;
|
|
3436
3596
|
}
|
|
3437
3597
|
if (isSecretInjectiveWalletConfig(config)) {
|
|
@@ -3444,6 +3604,7 @@ var InjectiveWalletProvider = class extends BaseWalletProvider {
|
|
|
3444
3604
|
throw new Error("Invalid Secret Injective wallet config");
|
|
3445
3605
|
}
|
|
3446
3606
|
this.wallet = { msgBroadcaster: new MsgBroadcasterWithPk({ privateKey, network: config.network }) };
|
|
3607
|
+
this.endpoints = getNetworkEndpoints(config.network);
|
|
3447
3608
|
return;
|
|
3448
3609
|
}
|
|
3449
3610
|
throw new Error("Invalid Injective wallet config");
|
|
@@ -3536,6 +3697,53 @@ var InjectiveWalletProvider = class extends BaseWalletProvider {
|
|
|
3536
3697
|
}
|
|
3537
3698
|
return txResponseToExecuteResponse(txResult);
|
|
3538
3699
|
}
|
|
3700
|
+
/**
|
|
3701
|
+
* Broadcasts an already-signed, proto-encoded Cosmos `TxRaw` via the configured gRPC endpoint.
|
|
3702
|
+
* @param signedTxRaw - The signed transaction, encoded with `TxRaw.encode(...).finish()`.
|
|
3703
|
+
* @returns The transaction hash.
|
|
3704
|
+
* @throws {Error} if the node rejects the transaction (non-zero result code).
|
|
3705
|
+
*/
|
|
3706
|
+
async sendTransaction(signedTxRaw) {
|
|
3707
|
+
const txRaw = TxRaw.decode(signedTxRaw);
|
|
3708
|
+
const res = await new TxGrpcApi(this.endpoints.grpc).broadcast(txRaw);
|
|
3709
|
+
if (res.code !== 0) {
|
|
3710
|
+
throw new Error(`Injective broadcast failed (code ${res.code}): ${res.rawLog}`);
|
|
3711
|
+
}
|
|
3712
|
+
return res.txHash;
|
|
3713
|
+
}
|
|
3714
|
+
/**
|
|
3715
|
+
* Signs and broadcasts an unsigned `InjectiveRawTransaction` (e.g. from the Swaps API).
|
|
3716
|
+
*
|
|
3717
|
+
* - **PK (secret) mode**: signs the exact unsigned `SignDoc` (`bodyBytes`/`authInfoBytes`) and
|
|
3718
|
+
* broadcasts it as-is, preserving the precise fee/account the Swaps API built.
|
|
3719
|
+
* - **Browser mode (Keplr/Leap/Metamask)**: an EVM wallet can't sign a raw Cosmos `SignDoc`, so we
|
|
3720
|
+
* recover the messages from `bodyBytes` and broadcast them through the fee-delegation path (same as
|
|
3721
|
+
* {@link execute}). The broadcaster builds the wallet-appropriate sign payload (DIRECT for Cosmos
|
|
3722
|
+
* wallets, EIP-712 for Metamask). Trade-off: the broadcaster recomputes gas/fee rather than using
|
|
3723
|
+
* the exact fee in the raw tx; the on-chain effect (the execute message) is unchanged.
|
|
3724
|
+
*
|
|
3725
|
+
* @returns The transaction hash.
|
|
3726
|
+
*/
|
|
3727
|
+
async signAndSendTransaction(tx) {
|
|
3728
|
+
const { bodyBytes, authInfoBytes, chainId, accountNumber } = tx.signedDoc;
|
|
3729
|
+
const signerAddress = await this.getWalletAddress();
|
|
3730
|
+
if (tx.from !== signerAddress) {
|
|
3731
|
+
throw new Error(`Injective: cannot sign transaction for ${tx.from} with wallet ${signerAddress}.`);
|
|
3732
|
+
}
|
|
3733
|
+
if (this.wallet.msgBroadcaster instanceof MsgBroadcasterWithPk) {
|
|
3734
|
+
const signDoc = SignDoc.fromPartial({ bodyBytes, authInfoBytes, chainId, accountNumber });
|
|
3735
|
+
const signBytes = SignDoc.encode(signDoc).finish();
|
|
3736
|
+
const signature = this.wallet.msgBroadcaster.privateKey.sign(Buffer.from(signBytes));
|
|
3737
|
+
const signedTxRaw = TxRaw.fromPartial({ bodyBytes, authInfoBytes, signatures: [signature] });
|
|
3738
|
+
return this.sendTransaction(TxRaw.encode(signedTxRaw).finish());
|
|
3739
|
+
}
|
|
3740
|
+
const msgs = decodeInjectiveExecuteMsgs(bodyBytes);
|
|
3741
|
+
const txResult = await this.wallet.msgBroadcaster.broadcastWithFeeDelegation({
|
|
3742
|
+
msgs,
|
|
3743
|
+
injectiveAddress: signerAddress
|
|
3744
|
+
});
|
|
3745
|
+
return txResult.txHash;
|
|
3746
|
+
}
|
|
3539
3747
|
};
|
|
3540
3748
|
var DEFAULT_CONNECTION_COMMITMENT = "confirmed";
|
|
3541
3749
|
var DEFAULT_CONFIRM_COMMITMENT = "finalized";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.0-rc.
|
|
7
|
+
"version": "2.0.0-rc.14",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"description": "Sodax Wallet SDK Core",
|
|
10
10
|
"keywords": [
|
|
@@ -61,13 +61,14 @@
|
|
|
61
61
|
"@stellar/stellar-sdk": "15.1.0",
|
|
62
62
|
"bip322-js": "^3.0.0",
|
|
63
63
|
"bitcoinjs-lib": "^6.1.5",
|
|
64
|
+
"cosmjs-types": "0.9.0",
|
|
64
65
|
"ecpair": "^2.0.1",
|
|
65
66
|
"icon-sdk-js": "1.5.3",
|
|
66
67
|
"near-api-js": "7.2.0",
|
|
67
68
|
"secp256k1": "^5.0.1",
|
|
68
69
|
"viem": "2.29.2",
|
|
69
|
-
"@sodax/
|
|
70
|
-
"@sodax/
|
|
70
|
+
"@sodax/libs": "2.0.0-rc.14",
|
|
71
|
+
"@sodax/types": "2.0.0-rc.14"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@arethetypeswrong/cli": "0.17.4",
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
"knip": "5.30.5",
|
|
79
80
|
"tsup": "8.5.0",
|
|
80
81
|
"typescript": "5.5.4",
|
|
81
|
-
"vitest": "3.2.
|
|
82
|
+
"vitest": "3.2.6"
|
|
82
83
|
},
|
|
83
84
|
"scripts": {
|
|
84
85
|
"build": "tsup",
|