@smoothsend/sdk 1.1.0 → 2.0.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/dist/adapters/aptos.d.ts +1 -0
- package/dist/adapters/aptos.d.ts.map +1 -1
- package/dist/adapters/stellar-c-address.d.ts +179 -0
- package/dist/adapters/stellar-c-address.d.ts.map +1 -0
- package/dist/adapters/stellar.d.ts +3 -0
- package/dist/adapters/stellar.d.ts.map +1 -1
- package/dist/index.d.ts +223 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +350 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +350 -15
- package/dist/index.js.map +1 -1
- package/dist/wallet-adapter/SmoothSendTransactionSubmitter.d.ts +12 -0
- package/dist/wallet-adapter/SmoothSendTransactionSubmitter.d.ts.map +1 -1
- package/package.json +5 -2
package/dist/index.esm.js
CHANGED
|
@@ -918,15 +918,27 @@ class AptosAdapter {
|
|
|
918
918
|
}
|
|
919
919
|
/**
|
|
920
920
|
* Get Aptos token address from symbol
|
|
921
|
+
* Mirrors aptosrelayer/config/chains.json
|
|
921
922
|
*/
|
|
922
923
|
getAptosTokenAddress(tokenSymbol) {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
924
|
+
const symbol = tokenSymbol.toUpperCase();
|
|
925
|
+
const TESTNET_TOKENS = {
|
|
926
|
+
USDC: '0x3c27315fb69ba6e4b960f1507d1cefcc9a4247869f26a8d59d6b7869d23782c::test_coins::USDC'
|
|
927
|
+
};
|
|
928
|
+
const MAINNET_TOKENS = {
|
|
929
|
+
USDT: '0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b',
|
|
930
|
+
USDC: '0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b',
|
|
931
|
+
WBTC: '0x68844a0d7f2587e726ad0579f3d640865bb4162c08a4589eeda3f9689ec52a3d',
|
|
932
|
+
USDE: '0xf37a8864fe737eb8ec2c2931047047cbaed1beed3fb0e5b7c5526dafd3b9c2e9',
|
|
933
|
+
USD1: '0x05fabd1b12e39967a3c24e91b7b8f67719a6dacee74f3c8b9fb7d93e855437d2'
|
|
934
|
+
};
|
|
935
|
+
const tokens = this.chain === 'aptos-testnet' ? TESTNET_TOKENS : MAINNET_TOKENS;
|
|
936
|
+
const address = tokens[symbol];
|
|
937
|
+
if (!address) {
|
|
938
|
+
const supported = Object.keys(tokens).join(', ');
|
|
939
|
+
throw new SmoothSendError(`Unsupported token: ${tokenSymbol} on ${this.chain}. Supported: ${supported}`, APTOS_ERROR_CODES.UNSUPPORTED_TOKEN, 400, { chain: this.chain, token: tokenSymbol, supported });
|
|
928
940
|
}
|
|
929
|
-
|
|
941
|
+
return address;
|
|
930
942
|
}
|
|
931
943
|
/**
|
|
932
944
|
* Build Aptos explorer URL for transaction
|
|
@@ -1043,6 +1055,279 @@ class AptosAdapter {
|
|
|
1043
1055
|
}
|
|
1044
1056
|
}
|
|
1045
1057
|
|
|
1058
|
+
/**
|
|
1059
|
+
* Stellar C-Address Adapter — SDK for Soroban Smart Account operations
|
|
1060
|
+
*
|
|
1061
|
+
* Provides a clean interface for:
|
|
1062
|
+
* - Creating C-addresses (smart accounts) from G-addresses
|
|
1063
|
+
* - Looking up existing C-addresses by owner
|
|
1064
|
+
* - Querying token balances (XLM, USDC, EURC)
|
|
1065
|
+
* - Building bridge transfers (G→C)
|
|
1066
|
+
* - Building smart account transfers (C→G, C→C)
|
|
1067
|
+
* - Submitting user-signed transactions via fee-bump
|
|
1068
|
+
* - Getting transaction history
|
|
1069
|
+
*
|
|
1070
|
+
* All transactions are gasless — the relayer covers fees via fee-bump.
|
|
1071
|
+
*
|
|
1072
|
+
* @example
|
|
1073
|
+
* ```typescript
|
|
1074
|
+
* import { SmoothSendSDK } from '@smoothsend/sdk';
|
|
1075
|
+
*
|
|
1076
|
+
* const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
|
|
1077
|
+
*
|
|
1078
|
+
* // Create a C-address for a G-address owner
|
|
1079
|
+
* const { cAddress } = await sdk.stellar.cAddress.create('GABCD...');
|
|
1080
|
+
*
|
|
1081
|
+
* // Get balances
|
|
1082
|
+
* const { balances } = await sdk.stellar.cAddress.getBalances(cAddress);
|
|
1083
|
+
*
|
|
1084
|
+
* // Build a bridge transfer (G→C), user signs, relayer fee-bumps
|
|
1085
|
+
* const { unsignedXDR } = await sdk.stellar.cAddress.buildBridgeTransfer({
|
|
1086
|
+
* from: 'GABCD...',
|
|
1087
|
+
* destination: cAddress,
|
|
1088
|
+
* asset: 'USDC',
|
|
1089
|
+
* amount: '10.5',
|
|
1090
|
+
* });
|
|
1091
|
+
* // Sign with wallet (e.g., Freighter)
|
|
1092
|
+
* const signedXDR = await wallet.signTransaction(unsignedXDR);
|
|
1093
|
+
* // Submit — relayer wraps in fee-bump
|
|
1094
|
+
* const { txHash } = await sdk.stellar.cAddress.submitTransfer(signedXDR);
|
|
1095
|
+
* ```
|
|
1096
|
+
*/
|
|
1097
|
+
class StellarCAddressAdapter {
|
|
1098
|
+
constructor(httpClient, network = 'testnet') {
|
|
1099
|
+
this.httpClient = httpClient;
|
|
1100
|
+
// Multi-chain compatible path: /api/v1/relayer/{chain}/c-address
|
|
1101
|
+
this.basePath = '/api/v1/relayer/stellar/c-address';
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Create a new C-address (Soroban Smart Account) for a G-address owner.
|
|
1105
|
+
* If the owner already has a C-address, returns the existing one.
|
|
1106
|
+
*
|
|
1107
|
+
* The relayer pays all deployment fees — completely gasless for the user.
|
|
1108
|
+
*
|
|
1109
|
+
* @param ownerGAddress - The G-address that will control this smart account
|
|
1110
|
+
* @returns The new C-address, tx hash, and whether it already existed
|
|
1111
|
+
*/
|
|
1112
|
+
async create(ownerGAddress) {
|
|
1113
|
+
this.validateGAddress(ownerGAddress);
|
|
1114
|
+
try {
|
|
1115
|
+
const response = await this.httpClient.post(`${this.basePath}/create`, { ownerGAddress }, { headers: { 'X-Chain': 'stellar' } });
|
|
1116
|
+
const data = response.data;
|
|
1117
|
+
if (!data.success) {
|
|
1118
|
+
throw new SmoothSendError(data.error || 'Failed to create C-address', 'C_ADDRESS_CREATE_FAILED', 500);
|
|
1119
|
+
}
|
|
1120
|
+
return {
|
|
1121
|
+
cAddress: data.cAddress,
|
|
1122
|
+
txHash: data.txHash,
|
|
1123
|
+
alreadyExisted: data.alreadyExisted,
|
|
1124
|
+
explorerUrl: data.explorerUrl,
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
catch (error) {
|
|
1128
|
+
if (error instanceof SmoothSendError)
|
|
1129
|
+
throw error;
|
|
1130
|
+
throw new SmoothSendError(`Failed to create C-address: ${error instanceof Error ? error.message : String(error)}`, 'C_ADDRESS_CREATE_FAILED', 500);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Look up the C-address for a given G-address owner.
|
|
1135
|
+
* Returns null if no C-address exists for this owner.
|
|
1136
|
+
*
|
|
1137
|
+
* @param ownerGAddress - The G-address to look up
|
|
1138
|
+
*/
|
|
1139
|
+
async lookup(ownerGAddress) {
|
|
1140
|
+
this.validateGAddress(ownerGAddress);
|
|
1141
|
+
try {
|
|
1142
|
+
const response = await this.httpClient.get(`${this.basePath}/lookup/${ownerGAddress}`, { headers: { 'X-Chain': 'stellar' } });
|
|
1143
|
+
const data = response.data;
|
|
1144
|
+
return {
|
|
1145
|
+
ownerGAddress: data.ownerGAddress,
|
|
1146
|
+
cAddress: data.cAddress || null,
|
|
1147
|
+
hasAccount: data.hasAccount,
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
catch (error) {
|
|
1151
|
+
if (error instanceof SmoothSendError)
|
|
1152
|
+
throw error;
|
|
1153
|
+
throw new SmoothSendError(`Failed to lookup C-address: ${error instanceof Error ? error.message : String(error)}`, 'C_ADDRESS_LOOKUP_FAILED', 500);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Get token balances for a C-address.
|
|
1158
|
+
* Returns balances for XLM, USDC, and EURC.
|
|
1159
|
+
*
|
|
1160
|
+
* @param cAddress - The C-address to query
|
|
1161
|
+
*/
|
|
1162
|
+
async getBalances(cAddress) {
|
|
1163
|
+
this.validateCAddress(cAddress);
|
|
1164
|
+
try {
|
|
1165
|
+
const response = await this.httpClient.get(`${this.basePath}/balance/${cAddress}`, { headers: { 'X-Chain': 'stellar' } });
|
|
1166
|
+
const data = response.data;
|
|
1167
|
+
return {
|
|
1168
|
+
cAddress: data.cAddress,
|
|
1169
|
+
balances: data.balances,
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
catch (error) {
|
|
1173
|
+
if (error instanceof SmoothSendError)
|
|
1174
|
+
throw error;
|
|
1175
|
+
throw new SmoothSendError(`Failed to get balances: ${error instanceof Error ? error.message : String(error)}`, 'C_ADDRESS_BALANCE_FAILED', 500);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Build a bridge transfer (G→C) using SAC.transfer.
|
|
1180
|
+
* Returns unsigned XDR for the user to sign with their wallet.
|
|
1181
|
+
* After signing, submit via submitTransfer().
|
|
1182
|
+
*
|
|
1183
|
+
* @param params.from - Sender G-address (signs the tx)
|
|
1184
|
+
* @param params.destination - Recipient C-address (or G-address)
|
|
1185
|
+
* @param params.asset - Asset to transfer: 'XLM', 'USDC', or 'EURC'
|
|
1186
|
+
* @param params.amount - Human-readable amount (e.g., '10.5')
|
|
1187
|
+
*/
|
|
1188
|
+
async buildBridgeTransfer(params) {
|
|
1189
|
+
this.validateGAddress(params.from);
|
|
1190
|
+
try {
|
|
1191
|
+
const response = await this.httpClient.post(`${this.basePath}/bridge-transfer`, params, { headers: { 'X-Chain': 'stellar' } });
|
|
1192
|
+
const data = response.data;
|
|
1193
|
+
if (!data.success) {
|
|
1194
|
+
throw new SmoothSendError(data.error || 'Bridge transfer failed', 'BRIDGE_TRANSFER_FAILED', 500);
|
|
1195
|
+
}
|
|
1196
|
+
return {
|
|
1197
|
+
unsignedXDR: data.unsignedXDR,
|
|
1198
|
+
networkPassphrase: data.networkPassphrase,
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
catch (error) {
|
|
1202
|
+
if (error instanceof SmoothSendError)
|
|
1203
|
+
throw error;
|
|
1204
|
+
throw new SmoothSendError(`Bridge transfer failed: ${error instanceof Error ? error.message : String(error)}`, 'BRIDGE_TRANSFER_FAILED', 500);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Build a transfer from a C-address (SmartAccount.send).
|
|
1209
|
+
* Returns unsigned XDR for the owner to sign.
|
|
1210
|
+
* After signing, submit via submitTransfer().
|
|
1211
|
+
*
|
|
1212
|
+
* @param params.from - Owner G-address (signs auth)
|
|
1213
|
+
* @param params.cAddress - Source C-address (holds the funds)
|
|
1214
|
+
* @param params.destination - Recipient (G or C address)
|
|
1215
|
+
* @param params.asset - Asset: 'XLM', 'USDC', or 'EURC'
|
|
1216
|
+
* @param params.amount - Human-readable amount
|
|
1217
|
+
*/
|
|
1218
|
+
async buildTransfer(params) {
|
|
1219
|
+
this.validateGAddress(params.from);
|
|
1220
|
+
this.validateCAddress(params.cAddress);
|
|
1221
|
+
try {
|
|
1222
|
+
const response = await this.httpClient.post(`${this.basePath}/build-transfer`, params, { headers: { 'X-Chain': 'stellar' } });
|
|
1223
|
+
const data = response.data;
|
|
1224
|
+
if (!data.success) {
|
|
1225
|
+
throw new SmoothSendError(data.error || 'Build transfer failed', 'BUILD_TRANSFER_FAILED', 500);
|
|
1226
|
+
}
|
|
1227
|
+
return {
|
|
1228
|
+
unsignedXDR: data.unsignedXDR,
|
|
1229
|
+
networkPassphrase: data.networkPassphrase,
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
catch (error) {
|
|
1233
|
+
if (error instanceof SmoothSendError)
|
|
1234
|
+
throw error;
|
|
1235
|
+
throw new SmoothSendError(`Build transfer failed: ${error instanceof Error ? error.message : String(error)}`, 'BUILD_TRANSFER_FAILED', 500);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Submit a user-signed transaction.
|
|
1240
|
+
* The relayer wraps it in a fee-bump transaction and submits to the network.
|
|
1241
|
+
* The user pays zero fees — the relayer covers everything.
|
|
1242
|
+
*
|
|
1243
|
+
* @param signedXDR - The user-signed transaction XDR (base64)
|
|
1244
|
+
*/
|
|
1245
|
+
async submitTransfer(signedXDR) {
|
|
1246
|
+
if (!signedXDR) {
|
|
1247
|
+
throw new SmoothSendError('signedXDR is required', 'MISSING_SIGNED_XDR', 400);
|
|
1248
|
+
}
|
|
1249
|
+
try {
|
|
1250
|
+
const response = await this.httpClient.post(`${this.basePath}/submit-transfer`, { signedXDR }, { headers: { 'X-Chain': 'stellar' } });
|
|
1251
|
+
const data = response.data;
|
|
1252
|
+
if (!data.success) {
|
|
1253
|
+
throw new SmoothSendError(data.error || 'Submit failed', 'SUBMIT_TRANSFER_FAILED', 500);
|
|
1254
|
+
}
|
|
1255
|
+
return {
|
|
1256
|
+
txHash: data.txHash,
|
|
1257
|
+
explorerUrl: data.explorerUrl,
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
catch (error) {
|
|
1261
|
+
if (error instanceof SmoothSendError)
|
|
1262
|
+
throw error;
|
|
1263
|
+
throw new SmoothSendError(`Submit transfer failed: ${error instanceof Error ? error.message : String(error)}`, 'SUBMIT_TRANSFER_FAILED', 500);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Get transaction history for a C-address.
|
|
1268
|
+
* Returns recent transfer events (sent/received) across all supported tokens.
|
|
1269
|
+
*
|
|
1270
|
+
* @param cAddress - The C-address to query
|
|
1271
|
+
* @param limit - Maximum number of transactions to return (default: 20)
|
|
1272
|
+
*/
|
|
1273
|
+
async getHistory(cAddress, limit = 20) {
|
|
1274
|
+
this.validateCAddress(cAddress);
|
|
1275
|
+
try {
|
|
1276
|
+
const response = await this.httpClient.get(`${this.basePath}/history/${cAddress}?limit=${limit}`, { headers: { 'X-Chain': 'stellar' } });
|
|
1277
|
+
const data = response.data;
|
|
1278
|
+
return {
|
|
1279
|
+
cAddress: data.cAddress,
|
|
1280
|
+
transactions: data.transactions || [],
|
|
1281
|
+
count: data.count || 0,
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
catch (error) {
|
|
1285
|
+
if (error instanceof SmoothSendError)
|
|
1286
|
+
throw error;
|
|
1287
|
+
throw new SmoothSendError(`Failed to get history: ${error instanceof Error ? error.message : String(error)}`, 'C_ADDRESS_HISTORY_FAILED', 500);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Health check for the C-address bridge service.
|
|
1292
|
+
*/
|
|
1293
|
+
async health() {
|
|
1294
|
+
try {
|
|
1295
|
+
const response = await this.httpClient.get(`${this.basePath}/health`, { headers: { 'X-Chain': 'stellar' } });
|
|
1296
|
+
const data = response.data;
|
|
1297
|
+
return {
|
|
1298
|
+
service: data.service,
|
|
1299
|
+
relayerPublicKey: data.relayerPublicKey,
|
|
1300
|
+
factoryContractId: data.factoryContractId,
|
|
1301
|
+
isReady: data.isReady,
|
|
1302
|
+
network: data.network,
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
catch (error) {
|
|
1306
|
+
if (error instanceof SmoothSendError)
|
|
1307
|
+
throw error;
|
|
1308
|
+
throw new SmoothSendError(`C-Address health check failed: ${error instanceof Error ? error.message : String(error)}`, 'C_ADDRESS_HEALTH_FAILED', 500);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
// ─────────────────────────────────────────────────────────
|
|
1312
|
+
// Validation helpers
|
|
1313
|
+
// ─────────────────────────────────────────────────────────
|
|
1314
|
+
validateGAddress(address) {
|
|
1315
|
+
if (!address || !address.startsWith('G') || address.length !== 56) {
|
|
1316
|
+
throw new SmoothSendError('Invalid G-address. Must start with G and be 56 characters.', 'INVALID_G_ADDRESS', 400);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
validateCAddress(address) {
|
|
1320
|
+
if (!address || !address.startsWith('C') || address.length !== 56) {
|
|
1321
|
+
throw new SmoothSendError('Invalid C-address. Must start with C and be 56 characters.', 'INVALID_C_ADDRESS', 400);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
validateAddress(address) {
|
|
1325
|
+
return (typeof address === 'string' &&
|
|
1326
|
+
address.length === 56 &&
|
|
1327
|
+
(address.startsWith('G') || address.startsWith('C')));
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1046
1331
|
/** Headers to route requests to Stellar relayer via proxy */
|
|
1047
1332
|
const STELLAR_HEADERS = { 'X-Chain': 'stellar' };
|
|
1048
1333
|
/**
|
|
@@ -1065,6 +1350,8 @@ class StellarAdapter {
|
|
|
1065
1350
|
retries: 3,
|
|
1066
1351
|
includeOrigin,
|
|
1067
1352
|
});
|
|
1353
|
+
// Initialize C-Address adapter (Soroban Smart Account)
|
|
1354
|
+
this.cAddress = new StellarCAddressAdapter(this.httpClient, network);
|
|
1068
1355
|
}
|
|
1069
1356
|
setNetwork(network) {
|
|
1070
1357
|
this.network = network;
|
|
@@ -1144,7 +1431,8 @@ class StellarAdapter {
|
|
|
1144
1431
|
}
|
|
1145
1432
|
}
|
|
1146
1433
|
validateAddress(address) {
|
|
1147
|
-
|
|
1434
|
+
// Support both G-addresses (classic) and C-addresses (Soroban smart accounts)
|
|
1435
|
+
return /^[GC][A-Z2-7]{55}$/.test(address);
|
|
1148
1436
|
}
|
|
1149
1437
|
validateAmount(amount) {
|
|
1150
1438
|
try {
|
|
@@ -1827,6 +2115,7 @@ class SmoothSendTransactionSubmitter {
|
|
|
1827
2115
|
this.network = config.network || 'testnet';
|
|
1828
2116
|
this.gatewayUrl = config.gatewayUrl || 'https://proxy.smoothsend.xyz';
|
|
1829
2117
|
this.timeout = config.timeout || 30000;
|
|
2118
|
+
this.getCaptchaToken = config.getCaptchaToken;
|
|
1830
2119
|
this.debug = config.debug || false;
|
|
1831
2120
|
}
|
|
1832
2121
|
/**
|
|
@@ -1837,26 +2126,34 @@ class SmoothSendTransactionSubmitter {
|
|
|
1837
2126
|
* SmoothSend's relayer which sponsors the gas fees.
|
|
1838
2127
|
*/
|
|
1839
2128
|
async submitTransaction(args) {
|
|
1840
|
-
const { transaction, senderAuthenticator, pluginParams } = args;
|
|
2129
|
+
const { aptosConfig, transaction, senderAuthenticator, pluginParams } = args;
|
|
2130
|
+
// Auto-detect network from aptosConfig (source of truth from wallet adapter)
|
|
2131
|
+
// Falls back to constructor value if aptosConfig doesn't have a recognized network
|
|
2132
|
+
const detectedNetwork = this.resolveNetwork(aptosConfig);
|
|
1841
2133
|
if (this.debug) {
|
|
1842
2134
|
console.log('[SmoothSend] Submitting gasless transaction:', {
|
|
1843
2135
|
sender: transaction.rawTransaction?.sender?.toString(),
|
|
1844
|
-
|
|
2136
|
+
configNetwork: this.network,
|
|
2137
|
+
detectedNetwork,
|
|
1845
2138
|
});
|
|
1846
2139
|
}
|
|
2140
|
+
if (detectedNetwork !== this.network && this.debug) {
|
|
2141
|
+
console.warn(`[SmoothSend] Network mismatch: constructor=${this.network}, aptosConfig=${detectedNetwork}. ` +
|
|
2142
|
+
`Using aptosConfig network (${detectedNetwork}).`);
|
|
2143
|
+
}
|
|
1847
2144
|
try {
|
|
1848
2145
|
// Serialize transaction and authenticator to bytes
|
|
1849
2146
|
const transactionBytes = Array.from(transaction.bcsToBytes());
|
|
1850
2147
|
const authenticatorBytes = Array.from(senderAuthenticator.bcsToBytes());
|
|
1851
|
-
// Prepare request payload
|
|
2148
|
+
// Prepare request payload — always use the detected network
|
|
1852
2149
|
const payload = {
|
|
1853
2150
|
transactionBytes,
|
|
1854
2151
|
authenticatorBytes,
|
|
1855
|
-
network:
|
|
2152
|
+
network: detectedNetwork,
|
|
1856
2153
|
functionName: pluginParams?.functionName || 'unknown',
|
|
1857
2154
|
};
|
|
1858
2155
|
// Make request to SmoothSend gateway
|
|
1859
|
-
const response = await this.makeRequest('/api/v1/relayer/gasless-transaction', payload);
|
|
2156
|
+
const response = await this.makeRequest('/api/v1/relayer/gasless-transaction', payload, detectedNetwork);
|
|
1860
2157
|
if (!response.success || !response.txnHash) {
|
|
1861
2158
|
throw new Error(response.error || response.details || 'Transaction submission failed');
|
|
1862
2159
|
}
|
|
@@ -1885,20 +2182,57 @@ class SmoothSendTransactionSubmitter {
|
|
|
1885
2182
|
throw new Error(`SmoothSend gasless transaction failed: ${error.message}`);
|
|
1886
2183
|
}
|
|
1887
2184
|
}
|
|
2185
|
+
/**
|
|
2186
|
+
* Resolve the effective network from aptosConfig.
|
|
2187
|
+
* aptosConfig.network is the source of truth set by AptosWalletAdapterProvider.
|
|
2188
|
+
*/
|
|
2189
|
+
resolveNetwork(aptosConfig) {
|
|
2190
|
+
try {
|
|
2191
|
+
const configNetwork = aptosConfig?.network;
|
|
2192
|
+
if (configNetwork === 'testnet' || configNetwork === 'mainnet') {
|
|
2193
|
+
return configNetwork;
|
|
2194
|
+
}
|
|
2195
|
+
if (typeof configNetwork === 'string') {
|
|
2196
|
+
const normalized = configNetwork.toLowerCase();
|
|
2197
|
+
if (normalized === 'testnet' || normalized === 'mainnet') {
|
|
2198
|
+
return normalized;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
catch {
|
|
2203
|
+
// fall through
|
|
2204
|
+
}
|
|
2205
|
+
return this.network;
|
|
2206
|
+
}
|
|
1888
2207
|
/**
|
|
1889
2208
|
* Make an HTTP request to the SmoothSend gateway
|
|
1890
2209
|
*/
|
|
1891
|
-
async makeRequest(endpoint, payload) {
|
|
2210
|
+
async makeRequest(endpoint, payload, network) {
|
|
2211
|
+
const effectiveNetwork = network || this.network;
|
|
1892
2212
|
const url = `${this.gatewayUrl}${endpoint}`;
|
|
1893
2213
|
const headers = {
|
|
1894
2214
|
'Content-Type': 'application/json',
|
|
1895
2215
|
'X-API-Key': this.apiKey,
|
|
1896
|
-
'X-Chain': `aptos-${
|
|
2216
|
+
'X-Chain': `aptos-${effectiveNetwork}`,
|
|
1897
2217
|
};
|
|
1898
2218
|
// Add Origin header for public keys in browser
|
|
1899
2219
|
if (this.apiKey.startsWith('pk_nogas_') && typeof window !== 'undefined') {
|
|
1900
2220
|
headers['Origin'] = window.location.origin;
|
|
1901
2221
|
}
|
|
2222
|
+
// Add captcha token if the project requires it
|
|
2223
|
+
if (this.getCaptchaToken) {
|
|
2224
|
+
try {
|
|
2225
|
+
const token = await this.getCaptchaToken();
|
|
2226
|
+
if (token) {
|
|
2227
|
+
headers['X-Captcha-Token'] = token;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
catch (e) {
|
|
2231
|
+
if (this.debug) {
|
|
2232
|
+
console.warn('[SmoothSend] Failed to get captcha token:', e);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
1902
2236
|
const controller = new AbortController();
|
|
1903
2237
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1904
2238
|
try {
|
|
@@ -2232,7 +2566,7 @@ function createScriptComposerClient(config) {
|
|
|
2232
2566
|
* SDK version
|
|
2233
2567
|
* @public
|
|
2234
2568
|
*/
|
|
2235
|
-
const VERSION = '
|
|
2569
|
+
const VERSION = '2.0.0'; // Multi-chain: Aptos + Stellar + C-Address
|
|
2236
2570
|
|
|
2237
|
-
export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, CHAIN_ECOSYSTEM_MAP, HttpClient, NetworkError, RateLimitError, STELLAR_ERROR_CODES, ScriptComposerClient, SmoothSendError, SmoothSendSDK, SmoothSendTransactionSubmitter, StellarAdapter, VERSION, ValidationError, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendSubmitter, SmoothSendSDK as default };
|
|
2571
|
+
export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, CHAIN_ECOSYSTEM_MAP, HttpClient, NetworkError, RateLimitError, STELLAR_ERROR_CODES, ScriptComposerClient, SmoothSendError, SmoothSendSDK, SmoothSendTransactionSubmitter, StellarAdapter, StellarCAddressAdapter, VERSION, ValidationError, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendSubmitter, SmoothSendSDK as default };
|
|
2238
2572
|
//# sourceMappingURL=index.esm.js.map
|