@dynamic-labs-wallet/node-evm 1.0.104 → 1.0.106
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/index.cjs +178 -21
- package/index.esm.js +175 -23
- package/package.json +3 -3
- package/src/client/gasless.client.d.ts +35 -14
- package/src/client/gasless.client.d.ts.map +1 -1
- package/src/client/gasless.types.d.ts +14 -6
- package/src/client/gasless.types.d.ts.map +1 -1
- package/src/client/index.d.ts +1 -1
- package/src/client/index.d.ts.map +1 -1
- package/src/delegatedGasless.d.ts +76 -0
- package/src/delegatedGasless.d.ts.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -110,7 +110,7 @@ const deriveAccountAddress = ({ rawPublicKey })=>{
|
|
|
110
110
|
};
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
const logError$
|
|
113
|
+
const logError$3 = node.createLogError('node-evm');
|
|
114
114
|
/**
|
|
115
115
|
* Creates a delegated EVM wallet client for functional operations
|
|
116
116
|
*/ const createDelegatedEvmWalletClient = ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug = false })=>{
|
|
@@ -149,7 +149,7 @@ const logError$2 = node.createLogError('node-evm');
|
|
|
149
149
|
});
|
|
150
150
|
return serializeECDSASignature(signatureEcdsa);
|
|
151
151
|
} catch (error) {
|
|
152
|
-
logError$
|
|
152
|
+
logError$3({
|
|
153
153
|
message: 'Error in delegatedSignMessage',
|
|
154
154
|
error: error,
|
|
155
155
|
context: {
|
|
@@ -198,7 +198,7 @@ const logError$2 = node.createLogError('node-evm');
|
|
|
198
198
|
});
|
|
199
199
|
return viem.serializeTransaction(signedTx);
|
|
200
200
|
} catch (error) {
|
|
201
|
-
logError$
|
|
201
|
+
logError$3({
|
|
202
202
|
message: 'Error in delegatedSignTransaction',
|
|
203
203
|
error: error,
|
|
204
204
|
context: {
|
|
@@ -231,7 +231,7 @@ const logError$2 = node.createLogError('node-evm');
|
|
|
231
231
|
});
|
|
232
232
|
return serializeECDSASignature(signatureEcdsa);
|
|
233
233
|
} catch (error) {
|
|
234
|
-
logError$
|
|
234
|
+
logError$3({
|
|
235
235
|
message: 'Error in delegatedSignTypedData',
|
|
236
236
|
error: error,
|
|
237
237
|
context: {
|
|
@@ -266,7 +266,7 @@ const logError$2 = node.createLogError('node-evm');
|
|
|
266
266
|
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
267
267
|
return viem.parseSignature(serializedSignature);
|
|
268
268
|
} catch (error) {
|
|
269
|
-
logError$
|
|
269
|
+
logError$3({
|
|
270
270
|
message: 'Error in delegatedSignAuthorization',
|
|
271
271
|
error: error,
|
|
272
272
|
context: {
|
|
@@ -299,7 +299,7 @@ const logError$2 = node.createLogError('node-evm');
|
|
|
299
299
|
});
|
|
300
300
|
return serializeECDSASignature(signatureEcdsa);
|
|
301
301
|
} catch (error) {
|
|
302
|
-
logError$
|
|
302
|
+
logError$3({
|
|
303
303
|
message: 'Error in delegatedSignRawMessage',
|
|
304
304
|
error: error,
|
|
305
305
|
context: {
|
|
@@ -486,11 +486,11 @@ const ERROR_GASLESS_MISSING_REQUEST_ID = 'Relay response did not include a reque
|
|
|
486
486
|
const ERROR_GASLESS_MISSING_YPARITY = 'Signed authorization is missing yParity';
|
|
487
487
|
const ERROR_GASLESS_RPC_REQUIRED = 'rpcUrl is required for this operation';
|
|
488
488
|
|
|
489
|
-
const logError$
|
|
489
|
+
const logError$2 = node.createLogError('node-evm');
|
|
490
490
|
/**
|
|
491
491
|
* Builds a stateless gasless client for EVM sponsored transactions (Fireblocks-relayer
|
|
492
492
|
* native gasless via EIP-7702 / AuthorizedExecutions). It holds no wallet state — the
|
|
493
|
-
* signing primitives and API client are injected by the
|
|
493
|
+
* signing primitives and API client are injected by the caller that owns the wallet.
|
|
494
494
|
*/ const createEvmGaslessClient = ({ apiClient, createViemPublicClient, signAuthorization, signTypedData })=>{
|
|
495
495
|
const viemPublicClientForChain = (chainId, rpcUrl)=>{
|
|
496
496
|
if (!rpcUrl) {
|
|
@@ -589,7 +589,7 @@ const logError$1 = node.createLogError('node-evm');
|
|
|
589
589
|
yParity: sig.yParity
|
|
590
590
|
};
|
|
591
591
|
} catch (error) {
|
|
592
|
-
logError$
|
|
592
|
+
logError$2({
|
|
593
593
|
message: 'Error signing 7702 authorization',
|
|
594
594
|
error: error,
|
|
595
595
|
context: {
|
|
@@ -696,7 +696,7 @@ const logError$1 = node.createLogError('node-evm');
|
|
|
696
696
|
walletAddress
|
|
697
697
|
};
|
|
698
698
|
} catch (error) {
|
|
699
|
-
logError$
|
|
699
|
+
logError$2({
|
|
700
700
|
message: 'Error signing sponsored transaction',
|
|
701
701
|
error: error,
|
|
702
702
|
context: {
|
|
@@ -751,7 +751,7 @@ const logError$1 = node.createLogError('node-evm');
|
|
|
751
751
|
accountAddress: params.walletMetadata.accountAddress,
|
|
752
752
|
chainId: params.chainId
|
|
753
753
|
};
|
|
754
|
-
logError$
|
|
754
|
+
logError$2({
|
|
755
755
|
message: 'Error relaying sponsored transaction',
|
|
756
756
|
error: error,
|
|
757
757
|
context: {
|
|
@@ -789,7 +789,7 @@ const logError$1 = node.createLogError('node-evm');
|
|
|
789
789
|
}
|
|
790
790
|
throw new Error(`${ERROR_GASLESS_TIMEOUT}: ${requestId}`);
|
|
791
791
|
} catch (error) {
|
|
792
|
-
logError$
|
|
792
|
+
logError$2({
|
|
793
793
|
message: 'Error waiting for sponsored transaction',
|
|
794
794
|
error: error,
|
|
795
795
|
context: {
|
|
@@ -818,7 +818,7 @@ const logError$1 = node.createLogError('node-evm');
|
|
|
818
818
|
};
|
|
819
819
|
};
|
|
820
820
|
|
|
821
|
-
const logError = node.createLogError('node-evm');
|
|
821
|
+
const logError$1 = node.createLogError('node-evm');
|
|
822
822
|
class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
823
823
|
get jwtAuthToken() {
|
|
824
824
|
return this.baseJWTAuthToken;
|
|
@@ -938,7 +938,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
938
938
|
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
939
939
|
};
|
|
940
940
|
} catch (error) {
|
|
941
|
-
logError({
|
|
941
|
+
logError$1({
|
|
942
942
|
message: ERROR_CREATE_WALLET_ACCOUNT,
|
|
943
943
|
error: error,
|
|
944
944
|
context: {}
|
|
@@ -970,7 +970,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
970
970
|
});
|
|
971
971
|
return serializeECDSASignature(signatureEcdsa);
|
|
972
972
|
} catch (error) {
|
|
973
|
-
logError({
|
|
973
|
+
logError$1({
|
|
974
974
|
message: ERROR_SIGN_MESSAGE,
|
|
975
975
|
error: error,
|
|
976
976
|
context: {
|
|
@@ -1020,7 +1020,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1020
1020
|
});
|
|
1021
1021
|
return viem.parseSignature(serializedSignature);
|
|
1022
1022
|
} catch (error) {
|
|
1023
|
-
logError({
|
|
1023
|
+
logError$1({
|
|
1024
1024
|
message: ERROR_SIGN_MESSAGE,
|
|
1025
1025
|
error: error,
|
|
1026
1026
|
context: {
|
|
@@ -1047,7 +1047,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1047
1047
|
onError
|
|
1048
1048
|
});
|
|
1049
1049
|
} catch (error) {
|
|
1050
|
-
logError({
|
|
1050
|
+
logError$1({
|
|
1051
1051
|
message: ERROR_SIGN_RAW_MESSAGE,
|
|
1052
1052
|
error: error,
|
|
1053
1053
|
context: {
|
|
@@ -1076,7 +1076,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1076
1076
|
onError
|
|
1077
1077
|
});
|
|
1078
1078
|
} catch (error) {
|
|
1079
|
-
logError({
|
|
1079
|
+
logError$1({
|
|
1080
1080
|
message: ERROR_SIGN_TYPED_DATA,
|
|
1081
1081
|
error: error,
|
|
1082
1082
|
context: {
|
|
@@ -1101,7 +1101,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1101
1101
|
});
|
|
1102
1102
|
return verified;
|
|
1103
1103
|
} catch (error) {
|
|
1104
|
-
logError({
|
|
1104
|
+
logError$1({
|
|
1105
1105
|
message: ERROR_VERIFY_MESSAGE_SIGNATURE,
|
|
1106
1106
|
error: error,
|
|
1107
1107
|
context: {
|
|
@@ -1145,7 +1145,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1145
1145
|
});
|
|
1146
1146
|
return serializedSignedTx;
|
|
1147
1147
|
} catch (error) {
|
|
1148
|
-
logError({
|
|
1148
|
+
logError$1({
|
|
1149
1149
|
message: 'Error signing transaction:',
|
|
1150
1150
|
error: error,
|
|
1151
1151
|
context: {
|
|
@@ -1212,7 +1212,7 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1212
1212
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
1213
1213
|
},
|
|
1214
1214
|
onError: (e)=>{
|
|
1215
|
-
logError({
|
|
1215
|
+
logError$1({
|
|
1216
1216
|
message: 'importPrivateKey: onError',
|
|
1217
1217
|
error: e,
|
|
1218
1218
|
context: {}
|
|
@@ -1330,6 +1330,158 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
|
+
function _object_without_properties_loose(source, excluded) {
|
|
1334
|
+
if (source == null) return {};
|
|
1335
|
+
var target = {};
|
|
1336
|
+
var sourceKeys = Object.keys(source);
|
|
1337
|
+
var key, i;
|
|
1338
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
1339
|
+
key = sourceKeys[i];
|
|
1340
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
1341
|
+
target[key] = source[key];
|
|
1342
|
+
}
|
|
1343
|
+
return target;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
const logError = node.createLogError('node-evm');
|
|
1347
|
+
const ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = 'Delegated key share, wallet ID, and wallet API key are required to sponsor a transaction';
|
|
1348
|
+
const ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = 'userId is required — a delegated wallet is always owned by an end user, so a sponsored transaction cannot be attributed to the calling service';
|
|
1349
|
+
const createViemPublicClient = ({ chain, rpcUrl })=>viem.createPublicClient({
|
|
1350
|
+
chain,
|
|
1351
|
+
transport: viem.http(rpcUrl)
|
|
1352
|
+
});
|
|
1353
|
+
const signerArgs = ({ keyShare, shareSetId, walletApiKey, walletId })=>({
|
|
1354
|
+
keyShare,
|
|
1355
|
+
shareSetId,
|
|
1356
|
+
walletApiKey,
|
|
1357
|
+
walletId
|
|
1358
|
+
});
|
|
1359
|
+
const gaslessFor = (client, apiClient, wallet)=>createEvmGaslessClient({
|
|
1360
|
+
apiClient,
|
|
1361
|
+
createViemPublicClient,
|
|
1362
|
+
signAuthorization: ({ authorization })=>delegatedSignAuthorization(client, _extends({}, signerArgs(wallet), {
|
|
1363
|
+
authorization
|
|
1364
|
+
})),
|
|
1365
|
+
signTypedData: ({ typedData })=>delegatedSignTypedData(client, _extends({}, signerArgs(wallet), {
|
|
1366
|
+
typedData
|
|
1367
|
+
}))
|
|
1368
|
+
});
|
|
1369
|
+
const walletRef = ({ walletAddress })=>({
|
|
1370
|
+
accountAddress: walletAddress
|
|
1371
|
+
});
|
|
1372
|
+
const assertDelegatedWallet = (wallet)=>{
|
|
1373
|
+
if (!wallet.keyShare || !wallet.walletId || !wallet.walletApiKey) {
|
|
1374
|
+
throw new Error(ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED);
|
|
1375
|
+
}
|
|
1376
|
+
if (!wallet.userId) {
|
|
1377
|
+
throw new Error(ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED);
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
const splitWallet = (params)=>{
|
|
1381
|
+
const { keyShare, shareSetId, userId, walletAddress, walletApiKey, walletId } = params, intent = _object_without_properties_loose(params, [
|
|
1382
|
+
"keyShare",
|
|
1383
|
+
"shareSetId",
|
|
1384
|
+
"userId",
|
|
1385
|
+
"walletAddress",
|
|
1386
|
+
"walletApiKey",
|
|
1387
|
+
"walletId"
|
|
1388
|
+
]);
|
|
1389
|
+
return {
|
|
1390
|
+
intent,
|
|
1391
|
+
wallet: {
|
|
1392
|
+
keyShare,
|
|
1393
|
+
shareSetId,
|
|
1394
|
+
userId,
|
|
1395
|
+
walletAddress,
|
|
1396
|
+
walletApiKey,
|
|
1397
|
+
walletId
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
};
|
|
1401
|
+
/**
|
|
1402
|
+
* Signs an EIP-7702 authorization delegating the end user's EOA to the UGD
|
|
1403
|
+
* contract, using the customer-held key share.
|
|
1404
|
+
*/ const delegatedSign7702Authorization = async (client, params)=>{
|
|
1405
|
+
const { chainId, nonce, rpcUrl } = params, wallet = _object_without_properties_loose(params, [
|
|
1406
|
+
"chainId",
|
|
1407
|
+
"nonce",
|
|
1408
|
+
"rpcUrl"
|
|
1409
|
+
]);
|
|
1410
|
+
assertDelegatedWallet(wallet);
|
|
1411
|
+
try {
|
|
1412
|
+
// The EOA nonce comes from the RPC and the signature from the delegated MPC
|
|
1413
|
+
// room, so this path makes no Dynamic-authenticated call.
|
|
1414
|
+
return await gaslessFor(client, client.createApiClient(), wallet).sign7702Authorization({
|
|
1415
|
+
chainId,
|
|
1416
|
+
nonce,
|
|
1417
|
+
rpcUrl,
|
|
1418
|
+
walletMetadata: walletRef(wallet)
|
|
1419
|
+
});
|
|
1420
|
+
} catch (error) {
|
|
1421
|
+
logError({
|
|
1422
|
+
message: 'Error in delegatedSign7702Authorization',
|
|
1423
|
+
error: error,
|
|
1424
|
+
context: {
|
|
1425
|
+
walletId: wallet.walletId
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
1428
|
+
throw error;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
/**
|
|
1432
|
+
* Signs the EIP-712 AuthorizedExecutions intent for a batch of calls, resolving
|
|
1433
|
+
* a first-use 7702 authorization along the way when the wallet is not yet delegated.
|
|
1434
|
+
*
|
|
1435
|
+
* The returned payload can be relayed later with `sendSponsoredTransaction` on a
|
|
1436
|
+
* `DynamicEvmWalletClient`, which needs no key share to submit an already-signed intent.
|
|
1437
|
+
*/ const delegatedSignSponsoredTransaction = async (client, params)=>{
|
|
1438
|
+
const { intent, wallet } = splitWallet(params);
|
|
1439
|
+
assertDelegatedWallet(wallet);
|
|
1440
|
+
try {
|
|
1441
|
+
return await node.withDelegatedServerAuth(client, (apiClient)=>gaslessFor(client, apiClient, wallet).signSponsoredTransaction(_extends({}, intent, {
|
|
1442
|
+
walletMetadata: walletRef(wallet)
|
|
1443
|
+
})));
|
|
1444
|
+
} catch (error) {
|
|
1445
|
+
logError({
|
|
1446
|
+
message: 'Error in delegatedSignSponsoredTransaction',
|
|
1447
|
+
error: error,
|
|
1448
|
+
context: {
|
|
1449
|
+
walletId: wallet.walletId
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
throw error;
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* Signs, relays, and waits for a sponsored transaction on behalf of the wallet's
|
|
1457
|
+
* owner, resolving once the relayer reports an on-chain hash.
|
|
1458
|
+
*/ const delegatedSendSponsoredTransaction = async (client, params)=>{
|
|
1459
|
+
const { intent, wallet } = splitWallet(params);
|
|
1460
|
+
assertDelegatedWallet(wallet);
|
|
1461
|
+
try {
|
|
1462
|
+
// Relaying and polling each take their own server-auth JWT. Sharing one would
|
|
1463
|
+
// put the whole poll window inside a single retry scope, so a 401 on a late
|
|
1464
|
+
// poll would replay the relay and sponsor the transaction twice.
|
|
1465
|
+
const { requestId } = await node.withDelegatedServerAuth(client, (apiClient)=>gaslessFor(client, apiClient, wallet).relaySponsoredTransaction(_extends({}, intent, {
|
|
1466
|
+
userId: wallet.userId,
|
|
1467
|
+
walletMetadata: walletRef(wallet)
|
|
1468
|
+
})));
|
|
1469
|
+
return await node.withDelegatedServerAuth(client, (apiClient)=>gaslessFor(client, apiClient, wallet).waitForSponsoredTransaction({
|
|
1470
|
+
requestId,
|
|
1471
|
+
traceContext: intent.traceContext
|
|
1472
|
+
}));
|
|
1473
|
+
} catch (error) {
|
|
1474
|
+
logError({
|
|
1475
|
+
message: 'Error in delegatedSendSponsoredTransaction',
|
|
1476
|
+
error: error,
|
|
1477
|
+
context: {
|
|
1478
|
+
walletId: wallet.walletId
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
throw error;
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1333
1485
|
const getJwtExpiration = (jwt)=>{
|
|
1334
1486
|
if (!jwt) {
|
|
1335
1487
|
return 0;
|
|
@@ -1521,6 +1673,8 @@ exports.DELEGATION_CONTRACT_ADDRESS = DELEGATION_CONTRACT_ADDRESS;
|
|
|
1521
1673
|
exports.DynamicEvmWalletClient = DynamicEvmWalletClient;
|
|
1522
1674
|
exports.ERROR_ACCOUNT_ADDRESS_REQUIRED = ERROR_ACCOUNT_ADDRESS_REQUIRED;
|
|
1523
1675
|
exports.ERROR_CREATE_WALLET_ACCOUNT = ERROR_CREATE_WALLET_ACCOUNT;
|
|
1676
|
+
exports.ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED;
|
|
1677
|
+
exports.ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED;
|
|
1524
1678
|
exports.ERROR_GASLESS_MISSING_REQUEST_ID = ERROR_GASLESS_MISSING_REQUEST_ID;
|
|
1525
1679
|
exports.ERROR_GASLESS_MISSING_YPARITY = ERROR_GASLESS_MISSING_YPARITY;
|
|
1526
1680
|
exports.ERROR_GASLESS_RELAY_FAILED = ERROR_GASLESS_RELAY_FAILED;
|
|
@@ -1539,9 +1693,12 @@ exports.UGD_ABI = UGD_ABI;
|
|
|
1539
1693
|
exports.createAccountAdapter = createAccountAdapter;
|
|
1540
1694
|
exports.createDelegatedEvmWalletClient = createDelegatedEvmWalletClient;
|
|
1541
1695
|
exports.createZerodevClient = createZerodevClient;
|
|
1696
|
+
exports.delegatedSendSponsoredTransaction = delegatedSendSponsoredTransaction;
|
|
1697
|
+
exports.delegatedSign7702Authorization = delegatedSign7702Authorization;
|
|
1542
1698
|
exports.delegatedSignAuthorization = delegatedSignAuthorization;
|
|
1543
1699
|
exports.delegatedSignMessage = delegatedSignMessage;
|
|
1544
1700
|
exports.delegatedSignRawMessage = delegatedSignRawMessage;
|
|
1701
|
+
exports.delegatedSignSponsoredTransaction = delegatedSignSponsoredTransaction;
|
|
1545
1702
|
exports.delegatedSignTransaction = delegatedSignTransaction;
|
|
1546
1703
|
exports.delegatedSignTypedData = delegatedSignTypedData;
|
|
1547
1704
|
exports.deriveAccountAddress = deriveAccountAddress;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toAccount } from 'viem/accounts';
|
|
2
|
-
import { MessageHash, createLogError, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, stripHexPrefix, revokeDelegation as revokeDelegation$1, DynamicWalletClient, getMPCChainConfig, WalletOperation } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import { MessageHash, createLogError, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, stripHexPrefix, revokeDelegation as revokeDelegation$1, DynamicWalletClient, getMPCChainConfig, WalletOperation, withDelegatedServerAuth } from '@dynamic-labs-wallet/node';
|
|
3
3
|
import { getAddress, stringToHex, bytesToHex, size, concat, hashTypedData, validateTypedData, serializeSignature, parseSignature, serializeTransaction, defineChain, createPublicClient, http, createWalletClient } from 'viem';
|
|
4
4
|
import { hashAuthorization } from 'viem/utils';
|
|
5
5
|
import { mainnet } from 'viem/chains';
|
|
@@ -108,7 +108,7 @@ const deriveAccountAddress = ({ rawPublicKey })=>{
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
const logError$
|
|
111
|
+
const logError$3 = createLogError('node-evm');
|
|
112
112
|
/**
|
|
113
113
|
* Creates a delegated EVM wallet client for functional operations
|
|
114
114
|
*/ const createDelegatedEvmWalletClient = ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug = false })=>{
|
|
@@ -147,7 +147,7 @@ const logError$2 = createLogError('node-evm');
|
|
|
147
147
|
});
|
|
148
148
|
return serializeECDSASignature(signatureEcdsa);
|
|
149
149
|
} catch (error) {
|
|
150
|
-
logError$
|
|
150
|
+
logError$3({
|
|
151
151
|
message: 'Error in delegatedSignMessage',
|
|
152
152
|
error: error,
|
|
153
153
|
context: {
|
|
@@ -196,7 +196,7 @@ const logError$2 = createLogError('node-evm');
|
|
|
196
196
|
});
|
|
197
197
|
return serializeTransaction(signedTx);
|
|
198
198
|
} catch (error) {
|
|
199
|
-
logError$
|
|
199
|
+
logError$3({
|
|
200
200
|
message: 'Error in delegatedSignTransaction',
|
|
201
201
|
error: error,
|
|
202
202
|
context: {
|
|
@@ -229,7 +229,7 @@ const logError$2 = createLogError('node-evm');
|
|
|
229
229
|
});
|
|
230
230
|
return serializeECDSASignature(signatureEcdsa);
|
|
231
231
|
} catch (error) {
|
|
232
|
-
logError$
|
|
232
|
+
logError$3({
|
|
233
233
|
message: 'Error in delegatedSignTypedData',
|
|
234
234
|
error: error,
|
|
235
235
|
context: {
|
|
@@ -264,7 +264,7 @@ const logError$2 = createLogError('node-evm');
|
|
|
264
264
|
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
265
265
|
return parseSignature(serializedSignature);
|
|
266
266
|
} catch (error) {
|
|
267
|
-
logError$
|
|
267
|
+
logError$3({
|
|
268
268
|
message: 'Error in delegatedSignAuthorization',
|
|
269
269
|
error: error,
|
|
270
270
|
context: {
|
|
@@ -297,7 +297,7 @@ const logError$2 = createLogError('node-evm');
|
|
|
297
297
|
});
|
|
298
298
|
return serializeECDSASignature(signatureEcdsa);
|
|
299
299
|
} catch (error) {
|
|
300
|
-
logError$
|
|
300
|
+
logError$3({
|
|
301
301
|
message: 'Error in delegatedSignRawMessage',
|
|
302
302
|
error: error,
|
|
303
303
|
context: {
|
|
@@ -484,11 +484,11 @@ const ERROR_GASLESS_MISSING_REQUEST_ID = 'Relay response did not include a reque
|
|
|
484
484
|
const ERROR_GASLESS_MISSING_YPARITY = 'Signed authorization is missing yParity';
|
|
485
485
|
const ERROR_GASLESS_RPC_REQUIRED = 'rpcUrl is required for this operation';
|
|
486
486
|
|
|
487
|
-
const logError$
|
|
487
|
+
const logError$2 = createLogError('node-evm');
|
|
488
488
|
/**
|
|
489
489
|
* Builds a stateless gasless client for EVM sponsored transactions (Fireblocks-relayer
|
|
490
490
|
* native gasless via EIP-7702 / AuthorizedExecutions). It holds no wallet state — the
|
|
491
|
-
* signing primitives and API client are injected by the
|
|
491
|
+
* signing primitives and API client are injected by the caller that owns the wallet.
|
|
492
492
|
*/ const createEvmGaslessClient = ({ apiClient, createViemPublicClient, signAuthorization, signTypedData })=>{
|
|
493
493
|
const viemPublicClientForChain = (chainId, rpcUrl)=>{
|
|
494
494
|
if (!rpcUrl) {
|
|
@@ -587,7 +587,7 @@ const logError$1 = createLogError('node-evm');
|
|
|
587
587
|
yParity: sig.yParity
|
|
588
588
|
};
|
|
589
589
|
} catch (error) {
|
|
590
|
-
logError$
|
|
590
|
+
logError$2({
|
|
591
591
|
message: 'Error signing 7702 authorization',
|
|
592
592
|
error: error,
|
|
593
593
|
context: {
|
|
@@ -694,7 +694,7 @@ const logError$1 = createLogError('node-evm');
|
|
|
694
694
|
walletAddress
|
|
695
695
|
};
|
|
696
696
|
} catch (error) {
|
|
697
|
-
logError$
|
|
697
|
+
logError$2({
|
|
698
698
|
message: 'Error signing sponsored transaction',
|
|
699
699
|
error: error,
|
|
700
700
|
context: {
|
|
@@ -749,7 +749,7 @@ const logError$1 = createLogError('node-evm');
|
|
|
749
749
|
accountAddress: params.walletMetadata.accountAddress,
|
|
750
750
|
chainId: params.chainId
|
|
751
751
|
};
|
|
752
|
-
logError$
|
|
752
|
+
logError$2({
|
|
753
753
|
message: 'Error relaying sponsored transaction',
|
|
754
754
|
error: error,
|
|
755
755
|
context: {
|
|
@@ -787,7 +787,7 @@ const logError$1 = createLogError('node-evm');
|
|
|
787
787
|
}
|
|
788
788
|
throw new Error(`${ERROR_GASLESS_TIMEOUT}: ${requestId}`);
|
|
789
789
|
} catch (error) {
|
|
790
|
-
logError$
|
|
790
|
+
logError$2({
|
|
791
791
|
message: 'Error waiting for sponsored transaction',
|
|
792
792
|
error: error,
|
|
793
793
|
context: {
|
|
@@ -816,7 +816,7 @@ const logError$1 = createLogError('node-evm');
|
|
|
816
816
|
};
|
|
817
817
|
};
|
|
818
818
|
|
|
819
|
-
const logError = createLogError('node-evm');
|
|
819
|
+
const logError$1 = createLogError('node-evm');
|
|
820
820
|
class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
821
821
|
get jwtAuthToken() {
|
|
822
822
|
return this.baseJWTAuthToken;
|
|
@@ -936,7 +936,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
936
936
|
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
937
937
|
};
|
|
938
938
|
} catch (error) {
|
|
939
|
-
logError({
|
|
939
|
+
logError$1({
|
|
940
940
|
message: ERROR_CREATE_WALLET_ACCOUNT,
|
|
941
941
|
error: error,
|
|
942
942
|
context: {}
|
|
@@ -968,7 +968,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
968
968
|
});
|
|
969
969
|
return serializeECDSASignature(signatureEcdsa);
|
|
970
970
|
} catch (error) {
|
|
971
|
-
logError({
|
|
971
|
+
logError$1({
|
|
972
972
|
message: ERROR_SIGN_MESSAGE,
|
|
973
973
|
error: error,
|
|
974
974
|
context: {
|
|
@@ -1018,7 +1018,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1018
1018
|
});
|
|
1019
1019
|
return parseSignature(serializedSignature);
|
|
1020
1020
|
} catch (error) {
|
|
1021
|
-
logError({
|
|
1021
|
+
logError$1({
|
|
1022
1022
|
message: ERROR_SIGN_MESSAGE,
|
|
1023
1023
|
error: error,
|
|
1024
1024
|
context: {
|
|
@@ -1045,7 +1045,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1045
1045
|
onError
|
|
1046
1046
|
});
|
|
1047
1047
|
} catch (error) {
|
|
1048
|
-
logError({
|
|
1048
|
+
logError$1({
|
|
1049
1049
|
message: ERROR_SIGN_RAW_MESSAGE,
|
|
1050
1050
|
error: error,
|
|
1051
1051
|
context: {
|
|
@@ -1074,7 +1074,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1074
1074
|
onError
|
|
1075
1075
|
});
|
|
1076
1076
|
} catch (error) {
|
|
1077
|
-
logError({
|
|
1077
|
+
logError$1({
|
|
1078
1078
|
message: ERROR_SIGN_TYPED_DATA,
|
|
1079
1079
|
error: error,
|
|
1080
1080
|
context: {
|
|
@@ -1099,7 +1099,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1099
1099
|
});
|
|
1100
1100
|
return verified;
|
|
1101
1101
|
} catch (error) {
|
|
1102
|
-
logError({
|
|
1102
|
+
logError$1({
|
|
1103
1103
|
message: ERROR_VERIFY_MESSAGE_SIGNATURE,
|
|
1104
1104
|
error: error,
|
|
1105
1105
|
context: {
|
|
@@ -1143,7 +1143,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1143
1143
|
});
|
|
1144
1144
|
return serializedSignedTx;
|
|
1145
1145
|
} catch (error) {
|
|
1146
|
-
logError({
|
|
1146
|
+
logError$1({
|
|
1147
1147
|
message: 'Error signing transaction:',
|
|
1148
1148
|
error: error,
|
|
1149
1149
|
context: {
|
|
@@ -1210,7 +1210,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1210
1210
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
1211
1211
|
},
|
|
1212
1212
|
onError: (e)=>{
|
|
1213
|
-
logError({
|
|
1213
|
+
logError$1({
|
|
1214
1214
|
message: 'importPrivateKey: onError',
|
|
1215
1215
|
error: e,
|
|
1216
1216
|
context: {}
|
|
@@ -1328,6 +1328,158 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
1330
|
|
|
1331
|
+
function _object_without_properties_loose(source, excluded) {
|
|
1332
|
+
if (source == null) return {};
|
|
1333
|
+
var target = {};
|
|
1334
|
+
var sourceKeys = Object.keys(source);
|
|
1335
|
+
var key, i;
|
|
1336
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
1337
|
+
key = sourceKeys[i];
|
|
1338
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
1339
|
+
target[key] = source[key];
|
|
1340
|
+
}
|
|
1341
|
+
return target;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
const logError = createLogError('node-evm');
|
|
1345
|
+
const ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = 'Delegated key share, wallet ID, and wallet API key are required to sponsor a transaction';
|
|
1346
|
+
const ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = 'userId is required — a delegated wallet is always owned by an end user, so a sponsored transaction cannot be attributed to the calling service';
|
|
1347
|
+
const createViemPublicClient = ({ chain, rpcUrl })=>createPublicClient({
|
|
1348
|
+
chain,
|
|
1349
|
+
transport: http(rpcUrl)
|
|
1350
|
+
});
|
|
1351
|
+
const signerArgs = ({ keyShare, shareSetId, walletApiKey, walletId })=>({
|
|
1352
|
+
keyShare,
|
|
1353
|
+
shareSetId,
|
|
1354
|
+
walletApiKey,
|
|
1355
|
+
walletId
|
|
1356
|
+
});
|
|
1357
|
+
const gaslessFor = (client, apiClient, wallet)=>createEvmGaslessClient({
|
|
1358
|
+
apiClient,
|
|
1359
|
+
createViemPublicClient,
|
|
1360
|
+
signAuthorization: ({ authorization })=>delegatedSignAuthorization(client, _extends({}, signerArgs(wallet), {
|
|
1361
|
+
authorization
|
|
1362
|
+
})),
|
|
1363
|
+
signTypedData: ({ typedData })=>delegatedSignTypedData(client, _extends({}, signerArgs(wallet), {
|
|
1364
|
+
typedData
|
|
1365
|
+
}))
|
|
1366
|
+
});
|
|
1367
|
+
const walletRef = ({ walletAddress })=>({
|
|
1368
|
+
accountAddress: walletAddress
|
|
1369
|
+
});
|
|
1370
|
+
const assertDelegatedWallet = (wallet)=>{
|
|
1371
|
+
if (!wallet.keyShare || !wallet.walletId || !wallet.walletApiKey) {
|
|
1372
|
+
throw new Error(ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED);
|
|
1373
|
+
}
|
|
1374
|
+
if (!wallet.userId) {
|
|
1375
|
+
throw new Error(ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED);
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
const splitWallet = (params)=>{
|
|
1379
|
+
const { keyShare, shareSetId, userId, walletAddress, walletApiKey, walletId } = params, intent = _object_without_properties_loose(params, [
|
|
1380
|
+
"keyShare",
|
|
1381
|
+
"shareSetId",
|
|
1382
|
+
"userId",
|
|
1383
|
+
"walletAddress",
|
|
1384
|
+
"walletApiKey",
|
|
1385
|
+
"walletId"
|
|
1386
|
+
]);
|
|
1387
|
+
return {
|
|
1388
|
+
intent,
|
|
1389
|
+
wallet: {
|
|
1390
|
+
keyShare,
|
|
1391
|
+
shareSetId,
|
|
1392
|
+
userId,
|
|
1393
|
+
walletAddress,
|
|
1394
|
+
walletApiKey,
|
|
1395
|
+
walletId
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
};
|
|
1399
|
+
/**
|
|
1400
|
+
* Signs an EIP-7702 authorization delegating the end user's EOA to the UGD
|
|
1401
|
+
* contract, using the customer-held key share.
|
|
1402
|
+
*/ const delegatedSign7702Authorization = async (client, params)=>{
|
|
1403
|
+
const { chainId, nonce, rpcUrl } = params, wallet = _object_without_properties_loose(params, [
|
|
1404
|
+
"chainId",
|
|
1405
|
+
"nonce",
|
|
1406
|
+
"rpcUrl"
|
|
1407
|
+
]);
|
|
1408
|
+
assertDelegatedWallet(wallet);
|
|
1409
|
+
try {
|
|
1410
|
+
// The EOA nonce comes from the RPC and the signature from the delegated MPC
|
|
1411
|
+
// room, so this path makes no Dynamic-authenticated call.
|
|
1412
|
+
return await gaslessFor(client, client.createApiClient(), wallet).sign7702Authorization({
|
|
1413
|
+
chainId,
|
|
1414
|
+
nonce,
|
|
1415
|
+
rpcUrl,
|
|
1416
|
+
walletMetadata: walletRef(wallet)
|
|
1417
|
+
});
|
|
1418
|
+
} catch (error) {
|
|
1419
|
+
logError({
|
|
1420
|
+
message: 'Error in delegatedSign7702Authorization',
|
|
1421
|
+
error: error,
|
|
1422
|
+
context: {
|
|
1423
|
+
walletId: wallet.walletId
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
throw error;
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
/**
|
|
1430
|
+
* Signs the EIP-712 AuthorizedExecutions intent for a batch of calls, resolving
|
|
1431
|
+
* a first-use 7702 authorization along the way when the wallet is not yet delegated.
|
|
1432
|
+
*
|
|
1433
|
+
* The returned payload can be relayed later with `sendSponsoredTransaction` on a
|
|
1434
|
+
* `DynamicEvmWalletClient`, which needs no key share to submit an already-signed intent.
|
|
1435
|
+
*/ const delegatedSignSponsoredTransaction = async (client, params)=>{
|
|
1436
|
+
const { intent, wallet } = splitWallet(params);
|
|
1437
|
+
assertDelegatedWallet(wallet);
|
|
1438
|
+
try {
|
|
1439
|
+
return await withDelegatedServerAuth(client, (apiClient)=>gaslessFor(client, apiClient, wallet).signSponsoredTransaction(_extends({}, intent, {
|
|
1440
|
+
walletMetadata: walletRef(wallet)
|
|
1441
|
+
})));
|
|
1442
|
+
} catch (error) {
|
|
1443
|
+
logError({
|
|
1444
|
+
message: 'Error in delegatedSignSponsoredTransaction',
|
|
1445
|
+
error: error,
|
|
1446
|
+
context: {
|
|
1447
|
+
walletId: wallet.walletId
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
throw error;
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
/**
|
|
1454
|
+
* Signs, relays, and waits for a sponsored transaction on behalf of the wallet's
|
|
1455
|
+
* owner, resolving once the relayer reports an on-chain hash.
|
|
1456
|
+
*/ const delegatedSendSponsoredTransaction = async (client, params)=>{
|
|
1457
|
+
const { intent, wallet } = splitWallet(params);
|
|
1458
|
+
assertDelegatedWallet(wallet);
|
|
1459
|
+
try {
|
|
1460
|
+
// Relaying and polling each take their own server-auth JWT. Sharing one would
|
|
1461
|
+
// put the whole poll window inside a single retry scope, so a 401 on a late
|
|
1462
|
+
// poll would replay the relay and sponsor the transaction twice.
|
|
1463
|
+
const { requestId } = await withDelegatedServerAuth(client, (apiClient)=>gaslessFor(client, apiClient, wallet).relaySponsoredTransaction(_extends({}, intent, {
|
|
1464
|
+
userId: wallet.userId,
|
|
1465
|
+
walletMetadata: walletRef(wallet)
|
|
1466
|
+
})));
|
|
1467
|
+
return await withDelegatedServerAuth(client, (apiClient)=>gaslessFor(client, apiClient, wallet).waitForSponsoredTransaction({
|
|
1468
|
+
requestId,
|
|
1469
|
+
traceContext: intent.traceContext
|
|
1470
|
+
}));
|
|
1471
|
+
} catch (error) {
|
|
1472
|
+
logError({
|
|
1473
|
+
message: 'Error in delegatedSendSponsoredTransaction',
|
|
1474
|
+
error: error,
|
|
1475
|
+
context: {
|
|
1476
|
+
walletId: wallet.walletId
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
throw error;
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1331
1483
|
const getJwtExpiration = (jwt)=>{
|
|
1332
1484
|
if (!jwt) {
|
|
1333
1485
|
return 0;
|
|
@@ -1511,4 +1663,4 @@ const createZerodevClient = async (evmClient)=>{
|
|
|
1511
1663
|
return client;
|
|
1512
1664
|
};
|
|
1513
1665
|
|
|
1514
|
-
export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_GASLESS_MISSING_REQUEST_ID, ERROR_GASLESS_MISSING_YPARITY, ERROR_GASLESS_RELAY_FAILED, ERROR_GASLESS_RPC_REQUIRED, ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE, ERROR_GASLESS_TIMEOUT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_RAW_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS, EVM_GASLESS_DEFAULT_TIMEOUT_MS, EVM_SIGN_MESSAGE_PREFIX, UGD_ABI, createAccountAdapter, createDelegatedEvmWalletClient, createZerodevClient, delegatedSignAuthorization, delegatedSignMessage, delegatedSignRawMessage, delegatedSignTransaction, delegatedSignTypedData, deriveAccountAddress, formatEVMMessage, formatTypedData, mapTransactionToEvmTransaction, revokeDelegation, serializeECDSASignature };
|
|
1666
|
+
export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED, ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED, ERROR_GASLESS_MISSING_REQUEST_ID, ERROR_GASLESS_MISSING_YPARITY, ERROR_GASLESS_RELAY_FAILED, ERROR_GASLESS_RPC_REQUIRED, ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE, ERROR_GASLESS_TIMEOUT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_RAW_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS, EVM_GASLESS_DEFAULT_TIMEOUT_MS, EVM_SIGN_MESSAGE_PREFIX, UGD_ABI, createAccountAdapter, createDelegatedEvmWalletClient, createZerodevClient, delegatedSendSponsoredTransaction, delegatedSign7702Authorization, delegatedSignAuthorization, delegatedSignMessage, delegatedSignRawMessage, delegatedSignSponsoredTransaction, delegatedSignTransaction, delegatedSignTypedData, deriveAccountAddress, formatEVMMessage, formatTypedData, mapTransactionToEvmTransaction, revokeDelegation, serializeECDSASignature };
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-evm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.106",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "1.0.
|
|
7
|
+
"@dynamic-labs-wallet/node": "1.0.106",
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "^0.0.1093",
|
|
9
9
|
"@dynamic-labs-sdk/client": "1.18.0",
|
|
10
10
|
"@dynamic-labs-sdk/zerodev": "1.18.0",
|
|
11
11
|
"@dynamic-labs-sdk/evm": "1.18.0",
|
|
12
12
|
"@zerodev/ecdsa-validator": "5.4.9",
|
|
13
13
|
"@zerodev/sdk": "5.4.36",
|
|
14
|
-
"@dynamic-labs-wallet/core": "1.0.
|
|
14
|
+
"@dynamic-labs-wallet/core": "1.0.106"
|
|
15
15
|
},
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
@@ -1,33 +1,54 @@
|
|
|
1
|
+
import { type ServerKeyShare, type WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
1
2
|
import type { DynamicApiClient } from '@dynamic-labs-wallet/core';
|
|
2
|
-
import { type Hex } from 'viem';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { type Chain, type Hex, type PublicClient, type TypedData } from 'viem';
|
|
4
|
+
import type { GaslessWalletRef, GetAvailableEvmGaslessRelayerParams, GetEVMSponsoredTransactionStatusParams, Is7702DelegationActiveParams, RelaySponsoredTransactionParams, SerializedAuthorization, Sign7702AuthorizationParams, SignedSponsoredTransaction, SignSponsoredTransactionParams, SponsoredTransactionStatusResult, WaitForSponsoredTransactionParams } from './gasless.types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Primitives the gasless client borrows from whoever owns the wallet. `TWallet` is
|
|
7
|
+
* the wallet reference handed back to the injected signers — full `WalletMetadata`
|
|
8
|
+
* for the class client, an address-only reference for delegated access.
|
|
9
|
+
*/
|
|
10
|
+
export type EvmGaslessClientDeps<TWallet extends GaslessWalletRef = WalletMetadata> = {
|
|
7
11
|
apiClient: DynamicApiClient;
|
|
8
|
-
createViemPublicClient:
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
createViemPublicClient: (args: {
|
|
13
|
+
chain: Chain;
|
|
14
|
+
rpcUrl?: string;
|
|
15
|
+
}) => PublicClient;
|
|
16
|
+
signAuthorization: (args: {
|
|
17
|
+
authorization: unknown;
|
|
18
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
19
|
+
password?: string;
|
|
20
|
+
walletMetadata: TWallet;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
r: string;
|
|
23
|
+
s: string;
|
|
24
|
+
yParity?: number;
|
|
25
|
+
}>;
|
|
26
|
+
signTypedData: (args: {
|
|
27
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
28
|
+
password?: string;
|
|
29
|
+
typedData: TypedData;
|
|
30
|
+
walletMetadata: TWallet;
|
|
31
|
+
}) => Promise<string>;
|
|
11
32
|
};
|
|
12
33
|
/**
|
|
13
34
|
* Builds a stateless gasless client for EVM sponsored transactions (Fireblocks-relayer
|
|
14
35
|
* native gasless via EIP-7702 / AuthorizedExecutions). It holds no wallet state — the
|
|
15
|
-
* signing primitives and API client are injected by the
|
|
36
|
+
* signing primitives and API client are injected by the caller that owns the wallet.
|
|
16
37
|
*/
|
|
17
|
-
export declare const createEvmGaslessClient: ({ apiClient, createViemPublicClient, signAuthorization, signTypedData, }: EvmGaslessClientDeps) => {
|
|
38
|
+
export declare const createEvmGaslessClient: <TWallet extends GaslessWalletRef = WalletMetadata>({ apiClient, createViemPublicClient, signAuthorization, signTypedData, }: EvmGaslessClientDeps<TWallet>) => {
|
|
18
39
|
getAvailableEvmGaslessRelayer: ({ chainId, traceContext, }: GetAvailableEvmGaslessRelayerParams) => Promise<{
|
|
19
40
|
relayerAddress: Hex;
|
|
20
41
|
}>;
|
|
21
42
|
getEVMSponsoredTransactionStatus: ({ requestId, traceContext, }: GetEVMSponsoredTransactionStatusParams) => Promise<SponsoredTransactionStatusResult>;
|
|
22
43
|
is7702DelegationActive: ({ walletAddress, chainId, rpcUrl, }: Is7702DelegationActiveParams) => Promise<boolean>;
|
|
23
|
-
relaySponsoredTransaction: (params: RelaySponsoredTransactionParams) => Promise<{
|
|
44
|
+
relaySponsoredTransaction: (params: RelaySponsoredTransactionParams<TWallet>) => Promise<{
|
|
24
45
|
requestId: string;
|
|
25
46
|
}>;
|
|
26
|
-
sendSponsoredTransaction: (params: RelaySponsoredTransactionParams) => Promise<{
|
|
47
|
+
sendSponsoredTransaction: (params: RelaySponsoredTransactionParams<TWallet>) => Promise<{
|
|
27
48
|
transactionHash: Hex;
|
|
28
49
|
}>;
|
|
29
|
-
sign7702Authorization: ({ walletMetadata, chainId, rpcUrl, nonce, password, externalServerKeyShares, }: Sign7702AuthorizationParams) => Promise<SerializedAuthorization>;
|
|
30
|
-
signSponsoredTransaction: ({ walletMetadata, calls, chainId, rpcUrl, authorization, autoDelegate, nonce: providedNonce, validForSeconds, password, externalServerKeyShares, traceContext, }: SignSponsoredTransactionParams) => Promise<SignedSponsoredTransaction>;
|
|
50
|
+
sign7702Authorization: ({ walletMetadata, chainId, rpcUrl, nonce, password, externalServerKeyShares, }: Sign7702AuthorizationParams<TWallet>) => Promise<SerializedAuthorization>;
|
|
51
|
+
signSponsoredTransaction: ({ walletMetadata, calls, chainId, rpcUrl, authorization, autoDelegate, nonce: providedNonce, validForSeconds, password, externalServerKeyShares, traceContext, }: SignSponsoredTransactionParams<TWallet>) => Promise<SignedSponsoredTransaction>;
|
|
31
52
|
waitForSponsoredTransaction: ({ requestId, pollInterval, timeout, traceContext, }: WaitForSponsoredTransactionParams) => Promise<{
|
|
32
53
|
transactionHash: Hex;
|
|
33
54
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gasless.client.d.ts","sourceRoot":"","sources":["../../src/client/gasless.client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gasless.client.d.ts","sourceRoot":"","sources":["../../src/client/gasless.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,cAAc,EAAqB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACxH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAiB5F,OAAO,KAAK,EACV,gBAAgB,EAChB,mCAAmC,EACnC,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,EAC/B,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,oBAAoB,CAAC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AC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC;4GAzSjC,2BAA2B,CAAC,OAAO,CAAC,KAAG,OAAO,CAAC,uBAAuB,CAAC;iMA+HvE,8BAA8B,CAAC,OAAO,CAAC,KAAG,OAAO,CAAC,0BAA0B,CAAC;uFAmI7E,iCAAiC,KAAG,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC;CA0DzE,CAAC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { ServerKeyShare, TraceContext, WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* The only thing the gasless intent builder needs to know about a wallet, so a
|
|
5
|
+
* caller holding just an address (delegated access) can drive the same code as
|
|
6
|
+
* one holding full `WalletMetadata`.
|
|
7
|
+
*/
|
|
8
|
+
export type GaslessWalletRef = {
|
|
9
|
+
accountAddress: string;
|
|
10
|
+
};
|
|
3
11
|
/** A single call within a sponsored transaction batch. */
|
|
4
12
|
export type SponsoredTransactionCall = {
|
|
5
13
|
/** Hex-encoded calldata to execute on the target. */
|
|
@@ -71,7 +79,7 @@ export type Is7702DelegationActiveParams = {
|
|
|
71
79
|
walletAddress: Hex;
|
|
72
80
|
};
|
|
73
81
|
/** Parameters for `sign7702Authorization`. */
|
|
74
|
-
export type Sign7702AuthorizationParams = {
|
|
82
|
+
export type Sign7702AuthorizationParams<TWallet extends GaslessWalletRef = WalletMetadata> = {
|
|
75
83
|
/** Target chain ID. */
|
|
76
84
|
chainId: number;
|
|
77
85
|
/** Optional externally supplied server key shares. */
|
|
@@ -83,7 +91,7 @@ export type Sign7702AuthorizationParams = {
|
|
|
83
91
|
/** RPC URL used to fetch the EOA nonce when `nonce` is omitted. */
|
|
84
92
|
rpcUrl?: string;
|
|
85
93
|
/** Metadata for the wallet signing the authorization. */
|
|
86
|
-
walletMetadata:
|
|
94
|
+
walletMetadata: TWallet;
|
|
87
95
|
};
|
|
88
96
|
/** Parameters for `getAvailableEvmGaslessRelayer`. */
|
|
89
97
|
export type GetAvailableEvmGaslessRelayerParams = {
|
|
@@ -93,7 +101,7 @@ export type GetAvailableEvmGaslessRelayerParams = {
|
|
|
93
101
|
traceContext?: TraceContext;
|
|
94
102
|
};
|
|
95
103
|
/** Parameters for `signSponsoredTransaction`. */
|
|
96
|
-
export type SignSponsoredTransactionParams = {
|
|
104
|
+
export type SignSponsoredTransactionParams<TWallet extends GaslessWalletRef = WalletMetadata> = {
|
|
97
105
|
/** Pre-signed EIP-7702 authorization; resolved automatically when omitted. */
|
|
98
106
|
authorization?: SerializedAuthorization;
|
|
99
107
|
/** When true, auto-sign a 7702 authorization if the wallet is not yet delegated. */
|
|
@@ -115,7 +123,7 @@ export type SignSponsoredTransactionParams = {
|
|
|
115
123
|
/** Intent validity window in seconds. */
|
|
116
124
|
validForSeconds?: number;
|
|
117
125
|
/** Metadata for the wallet signing the transaction. */
|
|
118
|
-
walletMetadata:
|
|
126
|
+
walletMetadata: TWallet;
|
|
119
127
|
};
|
|
120
128
|
/** Parameters for `getEVMSponsoredTransactionStatus`. */
|
|
121
129
|
export type GetEVMSponsoredTransactionStatusParams = {
|
|
@@ -128,14 +136,14 @@ export type GetEVMSponsoredTransactionStatusParams = {
|
|
|
128
136
|
* Parameters for `relaySponsoredTransaction` / `sendSponsoredTransaction`: either a pre-signed
|
|
129
137
|
* transaction or the inputs to sign one, optionally relayed on behalf of an end user.
|
|
130
138
|
*/
|
|
131
|
-
export type RelaySponsoredTransactionParams = {
|
|
139
|
+
export type RelaySponsoredTransactionParams<TWallet extends GaslessWalletRef = WalletMetadata> = {
|
|
132
140
|
/** A previously signed sponsored transaction. */
|
|
133
141
|
signedTransaction: SignedSponsoredTransaction;
|
|
134
142
|
/** Optional trace context for request correlation. */
|
|
135
143
|
traceContext?: TraceContext;
|
|
136
144
|
/** Relay on behalf of this end user; omit to relay as the authenticated service user. */
|
|
137
145
|
userId?: string;
|
|
138
|
-
} | (SignSponsoredTransactionParams & {
|
|
146
|
+
} | (SignSponsoredTransactionParams<TWallet> & {
|
|
139
147
|
/** Relay on behalf of this end user; omit to relay as the authenticated service user. */
|
|
140
148
|
userId?: string;
|
|
141
149
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gasless.types.d.ts","sourceRoot":"","sources":["../../src/client/gasless.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,0DAA0D;AAC1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,qDAAqD;IACrD,IAAI,EAAE,GAAG,CAAC;IACV,+BAA+B;IAC/B,MAAM,EAAE,GAAG,CAAC;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,uBAAuB,GAAG;IACpC,uCAAuC;IACvC,OAAO,EAAE,GAAG,CAAC;IACb,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,CAAC,EAAE,GAAG,CAAC;IACP,mCAAmC;IACnC,CAAC,EAAE,GAAG,CAAC;IACP,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEzF,6DAA6D;AAC7D,MAAM,MAAM,gCAAgC,GAAG;IAC7C,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,MAAM,EAAE,0BAA0B,CAAC;IACnC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,GAAG,CAAC;CACvB,CAAC;AA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C,GAAG;IACnD,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,CAAC,OAAO,SAAS,gBAAgB,GAAG,cAAc,IACzF;IACE,iDAAiD;IACjD,iBAAiB,EAAE,0BAA0B,CAAC;IAC9C,sDAAsD;IACtD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD,CAAC,8BAA8B,CAAC,OAAO,CAAC,GAAG;IACzC,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEP,oDAAoD;AACpD,MAAM,MAAM,iCAAiC,GAAG;IAC9C,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC"}
|
package/src/client/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export * from './accountAdapter.js';
|
|
|
2
2
|
export * from './client.js';
|
|
3
3
|
export * from './constants.js';
|
|
4
4
|
export * from '../utils.js';
|
|
5
|
-
export type { SerializedAuthorization, SignedSponsoredTransaction, SponsoredTransactionCall, SponsoredTransactionStatus, SponsoredTransactionStatusResult, } from './gasless.types.js';
|
|
5
|
+
export type { GaslessWalletRef, SerializedAuthorization, SignedSponsoredTransaction, SponsoredTransactionCall, SponsoredTransactionStatus, SponsoredTransactionStatusResult, } from './gasless.types.js';
|
|
6
6
|
export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, ERROR_GASLESS_MISSING_REQUEST_ID, ERROR_GASLESS_MISSING_YPARITY, ERROR_GASLESS_RELAY_FAILED, ERROR_GASLESS_RPC_REQUIRED, ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE, ERROR_GASLESS_TIMEOUT, EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS, EVM_GASLESS_DEFAULT_TIMEOUT_MS, UGD_ABI, } from './gasless.constants.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,YAAY,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAC3B,gCAAgC,EAChC,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,4CAA4C,EAC5C,qBAAqB,EACrB,oCAAoC,EACpC,8BAA8B,EAC9B,OAAO,GACR,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAC3B,gCAAgC,EAChC,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,4CAA4C,EAC5C,qBAAqB,EACrB,oCAAoC,EACpC,8BAA8B,EAC9B,OAAO,GACR,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type ServerKeyShare, type TraceContext } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import { type Hex } from 'viem';
|
|
3
|
+
import type { SerializedAuthorization, SignedSponsoredTransaction, SponsoredTransactionCall } from './client/gasless.types.js';
|
|
4
|
+
import { type DelegatedEvmWalletClient } from './delegatedClient.js';
|
|
5
|
+
export declare const ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = "Delegated key share, wallet ID, and wallet API key are required to sponsor a transaction";
|
|
6
|
+
export declare const ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = "userId is required \u2014 a delegated wallet is always owned by an end user, so a sponsored transaction cannot be attributed to the calling service";
|
|
7
|
+
/** Identifies the delegated wallet and its owner for a sponsored transaction. */
|
|
8
|
+
export type DelegatedGaslessWallet = {
|
|
9
|
+
/** The wallet's delegated key share, decrypted from `encryptedDelegatedShare`. */
|
|
10
|
+
keyShare: ServerKeyShare;
|
|
11
|
+
/**
|
|
12
|
+
* Optional. The `shareSetId` from the `wallet.delegation.created`
|
|
13
|
+
* webhook payload — a `WaasWallets.id`. NOT `keyShares[].id` from
|
|
14
|
+
* `byWalletAddress` (that's a `WalletKeyShares.id`, a different
|
|
15
|
+
* primary key). Omit and the server resolves the right share set
|
|
16
|
+
* by walletId + shareSetType.
|
|
17
|
+
*/
|
|
18
|
+
shareSetId?: string;
|
|
19
|
+
/** UUID of the end user who owns this wallet — the `userId` field of the webhook payload. */
|
|
20
|
+
userId: string;
|
|
21
|
+
/** The wallet's EOA address — the `publicKey` field of the webhook payload. */
|
|
22
|
+
walletAddress: Hex;
|
|
23
|
+
/** The wallet's API key, decrypted from `encryptedWalletApiKey`. */
|
|
24
|
+
walletApiKey: string;
|
|
25
|
+
/** The `walletId` from the `wallet.delegation.created` webhook payload. */
|
|
26
|
+
walletId: string;
|
|
27
|
+
};
|
|
28
|
+
/** Parameters for `delegatedSign7702Authorization`. */
|
|
29
|
+
export type DelegatedSign7702AuthorizationParams = DelegatedGaslessWallet & {
|
|
30
|
+
/** Target chain ID. */
|
|
31
|
+
chainId: number;
|
|
32
|
+
/** EOA nonce; fetched from the chain via `rpcUrl` when omitted. */
|
|
33
|
+
nonce?: number;
|
|
34
|
+
/** RPC URL used to fetch the EOA nonce when `nonce` is omitted. */
|
|
35
|
+
rpcUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
/** Parameters for `delegatedSignSponsoredTransaction` / `delegatedSendSponsoredTransaction`. */
|
|
38
|
+
export type DelegatedSignSponsoredTransactionParams = DelegatedGaslessWallet & {
|
|
39
|
+
/** Pre-signed EIP-7702 authorization; resolved automatically when omitted. */
|
|
40
|
+
authorization?: SerializedAuthorization;
|
|
41
|
+
/** When true, auto-sign a 7702 authorization if the wallet is not yet delegated. */
|
|
42
|
+
autoDelegate?: boolean;
|
|
43
|
+
/** The batch of calls to execute. */
|
|
44
|
+
calls: SponsoredTransactionCall[];
|
|
45
|
+
/** Target chain ID. */
|
|
46
|
+
chainId: number;
|
|
47
|
+
/** Explicit bitmap nonce; a random unused one is generated when omitted. */
|
|
48
|
+
nonce?: bigint;
|
|
49
|
+
/** RPC URL used for delegation checks and nonce validation. */
|
|
50
|
+
rpcUrl?: string;
|
|
51
|
+
/** Optional trace context for request correlation. */
|
|
52
|
+
traceContext?: TraceContext;
|
|
53
|
+
/** Intent validity window in seconds. */
|
|
54
|
+
validForSeconds?: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Signs an EIP-7702 authorization delegating the end user's EOA to the UGD
|
|
58
|
+
* contract, using the customer-held key share.
|
|
59
|
+
*/
|
|
60
|
+
export declare const delegatedSign7702Authorization: (client: DelegatedEvmWalletClient, params: DelegatedSign7702AuthorizationParams) => Promise<SerializedAuthorization>;
|
|
61
|
+
/**
|
|
62
|
+
* Signs the EIP-712 AuthorizedExecutions intent for a batch of calls, resolving
|
|
63
|
+
* a first-use 7702 authorization along the way when the wallet is not yet delegated.
|
|
64
|
+
*
|
|
65
|
+
* The returned payload can be relayed later with `sendSponsoredTransaction` on a
|
|
66
|
+
* `DynamicEvmWalletClient`, which needs no key share to submit an already-signed intent.
|
|
67
|
+
*/
|
|
68
|
+
export declare const delegatedSignSponsoredTransaction: (client: DelegatedEvmWalletClient, params: DelegatedSignSponsoredTransactionParams) => Promise<SignedSponsoredTransaction>;
|
|
69
|
+
/**
|
|
70
|
+
* Signs, relays, and waits for a sponsored transaction on behalf of the wallet's
|
|
71
|
+
* owner, resolving once the relayer reports an on-chain hash.
|
|
72
|
+
*/
|
|
73
|
+
export declare const delegatedSendSponsoredTransaction: (client: DelegatedEvmWalletClient, params: DelegatedSignSponsoredTransactionParams) => Promise<{
|
|
74
|
+
transactionHash: Hex;
|
|
75
|
+
}>;
|
|
76
|
+
//# sourceMappingURL=delegatedGasless.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegatedGasless.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedGasless.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAwC,KAAK,GAAG,EAAqB,MAAM,MAAM,CAAC;AAEzF,OAAO,KAAK,EAEV,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAC;AAI9B,eAAO,MAAM,4CAA4C,6FACmC,CAAC;AAE7F,eAAO,MAAM,wCAAwC,wJAC6F,CAAC;AAEnJ,iFAAiF;AACjF,MAAM,MAAM,sBA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AEF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,WACpC,wBAAwB,UACxB,uCAAuC,KAC9C,OAAO,CAAC;IAAE,eAAe,EAAE,GAAG,CAAA;CAAE,CA8BlC,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './delegatedClient.js';
|
|
3
|
+
export { delegatedSendSponsoredTransaction, delegatedSign7702Authorization, delegatedSignSponsoredTransaction, ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED, ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED, type DelegatedGaslessWallet, type DelegatedSign7702AuthorizationParams, type DelegatedSignSponsoredTransactionParams, } from './delegatedGasless.js';
|
|
3
4
|
export * from './zerodev/index.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EACL,iCAAiC,EACjC,8BAA8B,EAC9B,iCAAiC,EACjC,4CAA4C,EAC5C,wCAAwC,EACxC,KAAK,sBAAsB,EAC3B,KAAK,oCAAoC,EACzC,KAAK,uCAAuC,GAC7C,MAAM,uBAAuB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|