@proofchain/sdk 2.1.1 → 2.2.0
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.d.mts +159 -15
- package/dist/index.d.ts +159 -15
- package/dist/index.js +95 -6
- package/dist/index.mjs +95 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1007,13 +1007,6 @@ interface WalletBalance {
|
|
|
1007
1007
|
network: string;
|
|
1008
1008
|
balances: TokenBalance[];
|
|
1009
1009
|
}
|
|
1010
|
-
interface TokenBalance {
|
|
1011
|
-
token: string;
|
|
1012
|
-
symbol: string;
|
|
1013
|
-
balance: string;
|
|
1014
|
-
decimals: number;
|
|
1015
|
-
usd_value?: number;
|
|
1016
|
-
}
|
|
1017
1010
|
interface NFT {
|
|
1018
1011
|
id: string;
|
|
1019
1012
|
wallet_id: string;
|
|
@@ -1157,11 +1150,20 @@ interface AddNFTRequest {
|
|
|
1157
1150
|
source?: string;
|
|
1158
1151
|
}
|
|
1159
1152
|
interface TransferRequest {
|
|
1160
|
-
|
|
1153
|
+
/** Source wallet address (required if wallet_id not provided) */
|
|
1154
|
+
from_address?: string;
|
|
1155
|
+
/** Source wallet ID (alternative to from_address) */
|
|
1156
|
+
wallet_id?: string;
|
|
1157
|
+
/** Destination address */
|
|
1161
1158
|
to_address: string;
|
|
1159
|
+
/** Amount to transfer (in token units, e.g., "0.1" for 0.1 ETH) */
|
|
1162
1160
|
amount: string;
|
|
1161
|
+
/** Token symbol (default: "ETH") */
|
|
1163
1162
|
token?: string;
|
|
1163
|
+
/** Network (default: "base-sepolia") */
|
|
1164
1164
|
network?: string;
|
|
1165
|
+
/** Contract address for custom ERC-20 tokens */
|
|
1166
|
+
contract_address?: string;
|
|
1165
1167
|
}
|
|
1166
1168
|
interface TransferResult {
|
|
1167
1169
|
tx_hash: string;
|
|
@@ -1169,9 +1171,80 @@ interface TransferResult {
|
|
|
1169
1171
|
to: string;
|
|
1170
1172
|
amount: string;
|
|
1171
1173
|
token: string;
|
|
1174
|
+
contract_address?: string;
|
|
1172
1175
|
network: string;
|
|
1173
1176
|
status: string;
|
|
1174
1177
|
}
|
|
1178
|
+
interface Token {
|
|
1179
|
+
id: string;
|
|
1180
|
+
contract_address: string;
|
|
1181
|
+
network: string;
|
|
1182
|
+
symbol: string;
|
|
1183
|
+
name: string;
|
|
1184
|
+
decimals: number;
|
|
1185
|
+
logo_url?: string;
|
|
1186
|
+
color?: string;
|
|
1187
|
+
coingecko_id?: string;
|
|
1188
|
+
coinmarketcap_id?: string;
|
|
1189
|
+
token_standard: string;
|
|
1190
|
+
is_native_wrapper: boolean;
|
|
1191
|
+
is_verified: boolean;
|
|
1192
|
+
is_active: boolean;
|
|
1193
|
+
is_hidden?: boolean;
|
|
1194
|
+
display_order: number;
|
|
1195
|
+
is_global: boolean;
|
|
1196
|
+
}
|
|
1197
|
+
interface CreateTokenRequest {
|
|
1198
|
+
contract_address: string;
|
|
1199
|
+
network: string;
|
|
1200
|
+
symbol: string;
|
|
1201
|
+
name: string;
|
|
1202
|
+
decimals?: number;
|
|
1203
|
+
logo_url?: string;
|
|
1204
|
+
color?: string;
|
|
1205
|
+
coingecko_id?: string;
|
|
1206
|
+
coinmarketcap_id?: string;
|
|
1207
|
+
custom_price_feed_url?: string;
|
|
1208
|
+
is_native_wrapper?: boolean;
|
|
1209
|
+
display_order?: number;
|
|
1210
|
+
}
|
|
1211
|
+
interface UpdateTokenRequest {
|
|
1212
|
+
symbol?: string;
|
|
1213
|
+
name?: string;
|
|
1214
|
+
decimals?: number;
|
|
1215
|
+
logo_url?: string;
|
|
1216
|
+
color?: string;
|
|
1217
|
+
coingecko_id?: string;
|
|
1218
|
+
coinmarketcap_id?: string;
|
|
1219
|
+
custom_price_feed_url?: string;
|
|
1220
|
+
is_active?: boolean;
|
|
1221
|
+
is_hidden?: boolean;
|
|
1222
|
+
display_order?: number;
|
|
1223
|
+
}
|
|
1224
|
+
interface TokenBalance {
|
|
1225
|
+
token: string;
|
|
1226
|
+
symbol: string;
|
|
1227
|
+
balance: string;
|
|
1228
|
+
decimals: number;
|
|
1229
|
+
usd_value?: number;
|
|
1230
|
+
}
|
|
1231
|
+
interface TokenBalance {
|
|
1232
|
+
token: string;
|
|
1233
|
+
balance: string;
|
|
1234
|
+
raw_balance?: string;
|
|
1235
|
+
contract_address?: string;
|
|
1236
|
+
decimals: number;
|
|
1237
|
+
name?: string;
|
|
1238
|
+
logo_url?: string;
|
|
1239
|
+
source: 'cdp' | 'custom' | 'global';
|
|
1240
|
+
}
|
|
1241
|
+
interface WalletBalanceResponse {
|
|
1242
|
+
address: string;
|
|
1243
|
+
network: string;
|
|
1244
|
+
native_balance: string;
|
|
1245
|
+
native_symbol: string;
|
|
1246
|
+
balances: TokenBalance[];
|
|
1247
|
+
}
|
|
1175
1248
|
interface UserWithWallets {
|
|
1176
1249
|
user_id: string;
|
|
1177
1250
|
wallets: Array<{
|
|
@@ -1225,9 +1298,11 @@ declare class WalletClient {
|
|
|
1225
1298
|
*/
|
|
1226
1299
|
createDualBulk(userIds: string[], network?: string): Promise<DualWallets[]>;
|
|
1227
1300
|
/**
|
|
1228
|
-
* Get wallet balance
|
|
1301
|
+
* Get wallet balance including custom tokens.
|
|
1302
|
+
*
|
|
1303
|
+
* Returns native balance (ETH) plus all registered token balances.
|
|
1229
1304
|
*/
|
|
1230
|
-
getBalance(walletId: string): Promise<
|
|
1305
|
+
getBalance(walletId: string): Promise<WalletBalanceResponse>;
|
|
1231
1306
|
/**
|
|
1232
1307
|
* Get comprehensive wallet information in a single call.
|
|
1233
1308
|
*
|
|
@@ -1265,21 +1340,33 @@ declare class WalletClient {
|
|
|
1265
1340
|
warning: string;
|
|
1266
1341
|
}>;
|
|
1267
1342
|
/**
|
|
1268
|
-
* Transfer tokens from
|
|
1343
|
+
* Transfer tokens from a CDP wallet to any address.
|
|
1344
|
+
*
|
|
1345
|
+
* Supports native ETH and ERC-20 tokens. The source wallet must be a CDP-managed wallet.
|
|
1269
1346
|
*
|
|
1270
|
-
* @param request - Transfer details
|
|
1347
|
+
* @param request - Transfer details (use wallet_id or from_address)
|
|
1271
1348
|
* @returns Transaction result with hash and status
|
|
1272
1349
|
*
|
|
1273
1350
|
* @example
|
|
1274
1351
|
* ```typescript
|
|
1352
|
+
* // Transfer ETH using wallet_id
|
|
1275
1353
|
* const result = await client.wallets.transfer({
|
|
1276
|
-
*
|
|
1354
|
+
* wallet_id: 'd1096269-f986-4fa6-a1f5-1a29ef69f6e4',
|
|
1277
1355
|
* to_address: '0x456...',
|
|
1278
|
-
* amount: '0.
|
|
1356
|
+
* amount: '0.0001',
|
|
1279
1357
|
* token: 'ETH',
|
|
1280
|
-
* network: 'base-
|
|
1358
|
+
* network: 'base-mainnet',
|
|
1281
1359
|
* });
|
|
1282
1360
|
* console.log('TX Hash:', result.tx_hash);
|
|
1361
|
+
*
|
|
1362
|
+
* // Transfer using from_address
|
|
1363
|
+
* const result2 = await client.wallets.transfer({
|
|
1364
|
+
* from_address: '0xaA2e82E5fCF97003d409Bc90826F40cfc8F27510',
|
|
1365
|
+
* to_address: '0x456...',
|
|
1366
|
+
* amount: '0.0001',
|
|
1367
|
+
* token: 'ETH',
|
|
1368
|
+
* network: 'base-mainnet',
|
|
1369
|
+
* });
|
|
1283
1370
|
* ```
|
|
1284
1371
|
*/
|
|
1285
1372
|
transfer(request: TransferRequest): Promise<TransferResult>;
|
|
@@ -1318,6 +1405,63 @@ declare class WalletClient {
|
|
|
1318
1405
|
limit?: number;
|
|
1319
1406
|
offset?: number;
|
|
1320
1407
|
}): Promise<TransactionHistory>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Register a custom token for the tenant.
|
|
1410
|
+
*
|
|
1411
|
+
* This allows tracking balances and enabling transfers for custom ERC-20 tokens.
|
|
1412
|
+
*
|
|
1413
|
+
* @param request - Token details including contract address, symbol, decimals
|
|
1414
|
+
* @returns The created token
|
|
1415
|
+
*
|
|
1416
|
+
* @example
|
|
1417
|
+
* ```typescript
|
|
1418
|
+
* const token = await client.wallets.createToken({
|
|
1419
|
+
* contract_address: '0x...',
|
|
1420
|
+
* network: 'base-mainnet',
|
|
1421
|
+
* symbol: 'wSOL',
|
|
1422
|
+
* name: 'Wrapped Solana',
|
|
1423
|
+
* decimals: 9,
|
|
1424
|
+
* });
|
|
1425
|
+
* ```
|
|
1426
|
+
*/
|
|
1427
|
+
createToken(request: CreateTokenRequest): Promise<Token>;
|
|
1428
|
+
/**
|
|
1429
|
+
* List all tokens available to the tenant.
|
|
1430
|
+
*
|
|
1431
|
+
* Returns both tenant-specific tokens and global tokens.
|
|
1432
|
+
*
|
|
1433
|
+
* @param options - Filter options
|
|
1434
|
+
*/
|
|
1435
|
+
listTokens(options?: {
|
|
1436
|
+
network?: string;
|
|
1437
|
+
include_global?: boolean;
|
|
1438
|
+
include_hidden?: boolean;
|
|
1439
|
+
}): Promise<Token[]>;
|
|
1440
|
+
/**
|
|
1441
|
+
* List global tokens (available to all tenants).
|
|
1442
|
+
*
|
|
1443
|
+
* These are well-known tokens like USDC, WETH, DAI, etc.
|
|
1444
|
+
*/
|
|
1445
|
+
listGlobalTokens(network?: string): Promise<Token[]>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Get a specific token by ID.
|
|
1448
|
+
*/
|
|
1449
|
+
getToken(tokenId: string): Promise<Token>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Get a token by contract address and network.
|
|
1452
|
+
*/
|
|
1453
|
+
getTokenByContract(contractAddress: string, network: string): Promise<Token>;
|
|
1454
|
+
/**
|
|
1455
|
+
* Update a custom token.
|
|
1456
|
+
*/
|
|
1457
|
+
updateToken(tokenId: string, request: UpdateTokenRequest): Promise<Token>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Delete a custom token (soft delete).
|
|
1460
|
+
*/
|
|
1461
|
+
deleteToken(tokenId: string): Promise<{
|
|
1462
|
+
message: string;
|
|
1463
|
+
token_id: string;
|
|
1464
|
+
}>;
|
|
1321
1465
|
}
|
|
1322
1466
|
|
|
1323
1467
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1007,13 +1007,6 @@ interface WalletBalance {
|
|
|
1007
1007
|
network: string;
|
|
1008
1008
|
balances: TokenBalance[];
|
|
1009
1009
|
}
|
|
1010
|
-
interface TokenBalance {
|
|
1011
|
-
token: string;
|
|
1012
|
-
symbol: string;
|
|
1013
|
-
balance: string;
|
|
1014
|
-
decimals: number;
|
|
1015
|
-
usd_value?: number;
|
|
1016
|
-
}
|
|
1017
1010
|
interface NFT {
|
|
1018
1011
|
id: string;
|
|
1019
1012
|
wallet_id: string;
|
|
@@ -1157,11 +1150,20 @@ interface AddNFTRequest {
|
|
|
1157
1150
|
source?: string;
|
|
1158
1151
|
}
|
|
1159
1152
|
interface TransferRequest {
|
|
1160
|
-
|
|
1153
|
+
/** Source wallet address (required if wallet_id not provided) */
|
|
1154
|
+
from_address?: string;
|
|
1155
|
+
/** Source wallet ID (alternative to from_address) */
|
|
1156
|
+
wallet_id?: string;
|
|
1157
|
+
/** Destination address */
|
|
1161
1158
|
to_address: string;
|
|
1159
|
+
/** Amount to transfer (in token units, e.g., "0.1" for 0.1 ETH) */
|
|
1162
1160
|
amount: string;
|
|
1161
|
+
/** Token symbol (default: "ETH") */
|
|
1163
1162
|
token?: string;
|
|
1163
|
+
/** Network (default: "base-sepolia") */
|
|
1164
1164
|
network?: string;
|
|
1165
|
+
/** Contract address for custom ERC-20 tokens */
|
|
1166
|
+
contract_address?: string;
|
|
1165
1167
|
}
|
|
1166
1168
|
interface TransferResult {
|
|
1167
1169
|
tx_hash: string;
|
|
@@ -1169,9 +1171,80 @@ interface TransferResult {
|
|
|
1169
1171
|
to: string;
|
|
1170
1172
|
amount: string;
|
|
1171
1173
|
token: string;
|
|
1174
|
+
contract_address?: string;
|
|
1172
1175
|
network: string;
|
|
1173
1176
|
status: string;
|
|
1174
1177
|
}
|
|
1178
|
+
interface Token {
|
|
1179
|
+
id: string;
|
|
1180
|
+
contract_address: string;
|
|
1181
|
+
network: string;
|
|
1182
|
+
symbol: string;
|
|
1183
|
+
name: string;
|
|
1184
|
+
decimals: number;
|
|
1185
|
+
logo_url?: string;
|
|
1186
|
+
color?: string;
|
|
1187
|
+
coingecko_id?: string;
|
|
1188
|
+
coinmarketcap_id?: string;
|
|
1189
|
+
token_standard: string;
|
|
1190
|
+
is_native_wrapper: boolean;
|
|
1191
|
+
is_verified: boolean;
|
|
1192
|
+
is_active: boolean;
|
|
1193
|
+
is_hidden?: boolean;
|
|
1194
|
+
display_order: number;
|
|
1195
|
+
is_global: boolean;
|
|
1196
|
+
}
|
|
1197
|
+
interface CreateTokenRequest {
|
|
1198
|
+
contract_address: string;
|
|
1199
|
+
network: string;
|
|
1200
|
+
symbol: string;
|
|
1201
|
+
name: string;
|
|
1202
|
+
decimals?: number;
|
|
1203
|
+
logo_url?: string;
|
|
1204
|
+
color?: string;
|
|
1205
|
+
coingecko_id?: string;
|
|
1206
|
+
coinmarketcap_id?: string;
|
|
1207
|
+
custom_price_feed_url?: string;
|
|
1208
|
+
is_native_wrapper?: boolean;
|
|
1209
|
+
display_order?: number;
|
|
1210
|
+
}
|
|
1211
|
+
interface UpdateTokenRequest {
|
|
1212
|
+
symbol?: string;
|
|
1213
|
+
name?: string;
|
|
1214
|
+
decimals?: number;
|
|
1215
|
+
logo_url?: string;
|
|
1216
|
+
color?: string;
|
|
1217
|
+
coingecko_id?: string;
|
|
1218
|
+
coinmarketcap_id?: string;
|
|
1219
|
+
custom_price_feed_url?: string;
|
|
1220
|
+
is_active?: boolean;
|
|
1221
|
+
is_hidden?: boolean;
|
|
1222
|
+
display_order?: number;
|
|
1223
|
+
}
|
|
1224
|
+
interface TokenBalance {
|
|
1225
|
+
token: string;
|
|
1226
|
+
symbol: string;
|
|
1227
|
+
balance: string;
|
|
1228
|
+
decimals: number;
|
|
1229
|
+
usd_value?: number;
|
|
1230
|
+
}
|
|
1231
|
+
interface TokenBalance {
|
|
1232
|
+
token: string;
|
|
1233
|
+
balance: string;
|
|
1234
|
+
raw_balance?: string;
|
|
1235
|
+
contract_address?: string;
|
|
1236
|
+
decimals: number;
|
|
1237
|
+
name?: string;
|
|
1238
|
+
logo_url?: string;
|
|
1239
|
+
source: 'cdp' | 'custom' | 'global';
|
|
1240
|
+
}
|
|
1241
|
+
interface WalletBalanceResponse {
|
|
1242
|
+
address: string;
|
|
1243
|
+
network: string;
|
|
1244
|
+
native_balance: string;
|
|
1245
|
+
native_symbol: string;
|
|
1246
|
+
balances: TokenBalance[];
|
|
1247
|
+
}
|
|
1175
1248
|
interface UserWithWallets {
|
|
1176
1249
|
user_id: string;
|
|
1177
1250
|
wallets: Array<{
|
|
@@ -1225,9 +1298,11 @@ declare class WalletClient {
|
|
|
1225
1298
|
*/
|
|
1226
1299
|
createDualBulk(userIds: string[], network?: string): Promise<DualWallets[]>;
|
|
1227
1300
|
/**
|
|
1228
|
-
* Get wallet balance
|
|
1301
|
+
* Get wallet balance including custom tokens.
|
|
1302
|
+
*
|
|
1303
|
+
* Returns native balance (ETH) plus all registered token balances.
|
|
1229
1304
|
*/
|
|
1230
|
-
getBalance(walletId: string): Promise<
|
|
1305
|
+
getBalance(walletId: string): Promise<WalletBalanceResponse>;
|
|
1231
1306
|
/**
|
|
1232
1307
|
* Get comprehensive wallet information in a single call.
|
|
1233
1308
|
*
|
|
@@ -1265,21 +1340,33 @@ declare class WalletClient {
|
|
|
1265
1340
|
warning: string;
|
|
1266
1341
|
}>;
|
|
1267
1342
|
/**
|
|
1268
|
-
* Transfer tokens from
|
|
1343
|
+
* Transfer tokens from a CDP wallet to any address.
|
|
1344
|
+
*
|
|
1345
|
+
* Supports native ETH and ERC-20 tokens. The source wallet must be a CDP-managed wallet.
|
|
1269
1346
|
*
|
|
1270
|
-
* @param request - Transfer details
|
|
1347
|
+
* @param request - Transfer details (use wallet_id or from_address)
|
|
1271
1348
|
* @returns Transaction result with hash and status
|
|
1272
1349
|
*
|
|
1273
1350
|
* @example
|
|
1274
1351
|
* ```typescript
|
|
1352
|
+
* // Transfer ETH using wallet_id
|
|
1275
1353
|
* const result = await client.wallets.transfer({
|
|
1276
|
-
*
|
|
1354
|
+
* wallet_id: 'd1096269-f986-4fa6-a1f5-1a29ef69f6e4',
|
|
1277
1355
|
* to_address: '0x456...',
|
|
1278
|
-
* amount: '0.
|
|
1356
|
+
* amount: '0.0001',
|
|
1279
1357
|
* token: 'ETH',
|
|
1280
|
-
* network: 'base-
|
|
1358
|
+
* network: 'base-mainnet',
|
|
1281
1359
|
* });
|
|
1282
1360
|
* console.log('TX Hash:', result.tx_hash);
|
|
1361
|
+
*
|
|
1362
|
+
* // Transfer using from_address
|
|
1363
|
+
* const result2 = await client.wallets.transfer({
|
|
1364
|
+
* from_address: '0xaA2e82E5fCF97003d409Bc90826F40cfc8F27510',
|
|
1365
|
+
* to_address: '0x456...',
|
|
1366
|
+
* amount: '0.0001',
|
|
1367
|
+
* token: 'ETH',
|
|
1368
|
+
* network: 'base-mainnet',
|
|
1369
|
+
* });
|
|
1283
1370
|
* ```
|
|
1284
1371
|
*/
|
|
1285
1372
|
transfer(request: TransferRequest): Promise<TransferResult>;
|
|
@@ -1318,6 +1405,63 @@ declare class WalletClient {
|
|
|
1318
1405
|
limit?: number;
|
|
1319
1406
|
offset?: number;
|
|
1320
1407
|
}): Promise<TransactionHistory>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Register a custom token for the tenant.
|
|
1410
|
+
*
|
|
1411
|
+
* This allows tracking balances and enabling transfers for custom ERC-20 tokens.
|
|
1412
|
+
*
|
|
1413
|
+
* @param request - Token details including contract address, symbol, decimals
|
|
1414
|
+
* @returns The created token
|
|
1415
|
+
*
|
|
1416
|
+
* @example
|
|
1417
|
+
* ```typescript
|
|
1418
|
+
* const token = await client.wallets.createToken({
|
|
1419
|
+
* contract_address: '0x...',
|
|
1420
|
+
* network: 'base-mainnet',
|
|
1421
|
+
* symbol: 'wSOL',
|
|
1422
|
+
* name: 'Wrapped Solana',
|
|
1423
|
+
* decimals: 9,
|
|
1424
|
+
* });
|
|
1425
|
+
* ```
|
|
1426
|
+
*/
|
|
1427
|
+
createToken(request: CreateTokenRequest): Promise<Token>;
|
|
1428
|
+
/**
|
|
1429
|
+
* List all tokens available to the tenant.
|
|
1430
|
+
*
|
|
1431
|
+
* Returns both tenant-specific tokens and global tokens.
|
|
1432
|
+
*
|
|
1433
|
+
* @param options - Filter options
|
|
1434
|
+
*/
|
|
1435
|
+
listTokens(options?: {
|
|
1436
|
+
network?: string;
|
|
1437
|
+
include_global?: boolean;
|
|
1438
|
+
include_hidden?: boolean;
|
|
1439
|
+
}): Promise<Token[]>;
|
|
1440
|
+
/**
|
|
1441
|
+
* List global tokens (available to all tenants).
|
|
1442
|
+
*
|
|
1443
|
+
* These are well-known tokens like USDC, WETH, DAI, etc.
|
|
1444
|
+
*/
|
|
1445
|
+
listGlobalTokens(network?: string): Promise<Token[]>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Get a specific token by ID.
|
|
1448
|
+
*/
|
|
1449
|
+
getToken(tokenId: string): Promise<Token>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Get a token by contract address and network.
|
|
1452
|
+
*/
|
|
1453
|
+
getTokenByContract(contractAddress: string, network: string): Promise<Token>;
|
|
1454
|
+
/**
|
|
1455
|
+
* Update a custom token.
|
|
1456
|
+
*/
|
|
1457
|
+
updateToken(tokenId: string, request: UpdateTokenRequest): Promise<Token>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Delete a custom token (soft delete).
|
|
1460
|
+
*/
|
|
1461
|
+
deleteToken(tokenId: string): Promise<{
|
|
1462
|
+
message: string;
|
|
1463
|
+
token_id: string;
|
|
1464
|
+
}>;
|
|
1321
1465
|
}
|
|
1322
1466
|
|
|
1323
1467
|
/**
|
package/dist/index.js
CHANGED
|
@@ -887,7 +887,9 @@ var WalletClient = class {
|
|
|
887
887
|
// Balances
|
|
888
888
|
// ---------------------------------------------------------------------------
|
|
889
889
|
/**
|
|
890
|
-
* Get wallet balance
|
|
890
|
+
* Get wallet balance including custom tokens.
|
|
891
|
+
*
|
|
892
|
+
* Returns native balance (ETH) plus all registered token balances.
|
|
891
893
|
*/
|
|
892
894
|
async getBalance(walletId) {
|
|
893
895
|
return this.http.get(`/wallets/${walletId}/balance`);
|
|
@@ -951,21 +953,33 @@ var WalletClient = class {
|
|
|
951
953
|
// Token Transfers
|
|
952
954
|
// ---------------------------------------------------------------------------
|
|
953
955
|
/**
|
|
954
|
-
* Transfer tokens from
|
|
956
|
+
* Transfer tokens from a CDP wallet to any address.
|
|
957
|
+
*
|
|
958
|
+
* Supports native ETH and ERC-20 tokens. The source wallet must be a CDP-managed wallet.
|
|
955
959
|
*
|
|
956
|
-
* @param request - Transfer details
|
|
960
|
+
* @param request - Transfer details (use wallet_id or from_address)
|
|
957
961
|
* @returns Transaction result with hash and status
|
|
958
962
|
*
|
|
959
963
|
* @example
|
|
960
964
|
* ```typescript
|
|
965
|
+
* // Transfer ETH using wallet_id
|
|
961
966
|
* const result = await client.wallets.transfer({
|
|
962
|
-
*
|
|
967
|
+
* wallet_id: 'd1096269-f986-4fa6-a1f5-1a29ef69f6e4',
|
|
963
968
|
* to_address: '0x456...',
|
|
964
|
-
* amount: '0.
|
|
969
|
+
* amount: '0.0001',
|
|
965
970
|
* token: 'ETH',
|
|
966
|
-
* network: 'base-
|
|
971
|
+
* network: 'base-mainnet',
|
|
967
972
|
* });
|
|
968
973
|
* console.log('TX Hash:', result.tx_hash);
|
|
974
|
+
*
|
|
975
|
+
* // Transfer using from_address
|
|
976
|
+
* const result2 = await client.wallets.transfer({
|
|
977
|
+
* from_address: '0xaA2e82E5fCF97003d409Bc90826F40cfc8F27510',
|
|
978
|
+
* to_address: '0x456...',
|
|
979
|
+
* amount: '0.0001',
|
|
980
|
+
* token: 'ETH',
|
|
981
|
+
* network: 'base-mainnet',
|
|
982
|
+
* });
|
|
969
983
|
* ```
|
|
970
984
|
*/
|
|
971
985
|
async transfer(request) {
|
|
@@ -1034,6 +1048,81 @@ var WalletClient = class {
|
|
|
1034
1048
|
`/wallets/${walletId}/transactions${query ? `?${query}` : ""}`
|
|
1035
1049
|
);
|
|
1036
1050
|
}
|
|
1051
|
+
// ---------------------------------------------------------------------------
|
|
1052
|
+
// Token Management
|
|
1053
|
+
// ---------------------------------------------------------------------------
|
|
1054
|
+
/**
|
|
1055
|
+
* Register a custom token for the tenant.
|
|
1056
|
+
*
|
|
1057
|
+
* This allows tracking balances and enabling transfers for custom ERC-20 tokens.
|
|
1058
|
+
*
|
|
1059
|
+
* @param request - Token details including contract address, symbol, decimals
|
|
1060
|
+
* @returns The created token
|
|
1061
|
+
*
|
|
1062
|
+
* @example
|
|
1063
|
+
* ```typescript
|
|
1064
|
+
* const token = await client.wallets.createToken({
|
|
1065
|
+
* contract_address: '0x...',
|
|
1066
|
+
* network: 'base-mainnet',
|
|
1067
|
+
* symbol: 'wSOL',
|
|
1068
|
+
* name: 'Wrapped Solana',
|
|
1069
|
+
* decimals: 9,
|
|
1070
|
+
* });
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
1073
|
+
async createToken(request) {
|
|
1074
|
+
return this.http.post("/tokens", request);
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* List all tokens available to the tenant.
|
|
1078
|
+
*
|
|
1079
|
+
* Returns both tenant-specific tokens and global tokens.
|
|
1080
|
+
*
|
|
1081
|
+
* @param options - Filter options
|
|
1082
|
+
*/
|
|
1083
|
+
async listTokens(options = {}) {
|
|
1084
|
+
const params = new URLSearchParams();
|
|
1085
|
+
if (options.network) params.set("network", options.network);
|
|
1086
|
+
if (options.include_global !== void 0) params.set("include_global", String(options.include_global));
|
|
1087
|
+
if (options.include_hidden !== void 0) params.set("include_hidden", String(options.include_hidden));
|
|
1088
|
+
const query = params.toString();
|
|
1089
|
+
return this.http.get(`/tokens${query ? `?${query}` : ""}`);
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* List global tokens (available to all tenants).
|
|
1093
|
+
*
|
|
1094
|
+
* These are well-known tokens like USDC, WETH, DAI, etc.
|
|
1095
|
+
*/
|
|
1096
|
+
async listGlobalTokens(network) {
|
|
1097
|
+
const params = network ? `?network=${network}` : "";
|
|
1098
|
+
return this.http.get(`/tokens/global${params}`);
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Get a specific token by ID.
|
|
1102
|
+
*/
|
|
1103
|
+
async getToken(tokenId) {
|
|
1104
|
+
return this.http.get(`/tokens/${tokenId}`);
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Get a token by contract address and network.
|
|
1108
|
+
*/
|
|
1109
|
+
async getTokenByContract(contractAddress, network) {
|
|
1110
|
+
return this.http.get(
|
|
1111
|
+
`/tokens/by-contract/${contractAddress}?network=${encodeURIComponent(network)}`
|
|
1112
|
+
);
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Update a custom token.
|
|
1116
|
+
*/
|
|
1117
|
+
async updateToken(tokenId, request) {
|
|
1118
|
+
return this.http.patch(`/tokens/${tokenId}`, request);
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Delete a custom token (soft delete).
|
|
1122
|
+
*/
|
|
1123
|
+
async deleteToken(tokenId) {
|
|
1124
|
+
return this.http.delete(`/tokens/${tokenId}`);
|
|
1125
|
+
}
|
|
1037
1126
|
};
|
|
1038
1127
|
|
|
1039
1128
|
// src/users.ts
|
package/dist/index.mjs
CHANGED
|
@@ -835,7 +835,9 @@ var WalletClient = class {
|
|
|
835
835
|
// Balances
|
|
836
836
|
// ---------------------------------------------------------------------------
|
|
837
837
|
/**
|
|
838
|
-
* Get wallet balance
|
|
838
|
+
* Get wallet balance including custom tokens.
|
|
839
|
+
*
|
|
840
|
+
* Returns native balance (ETH) plus all registered token balances.
|
|
839
841
|
*/
|
|
840
842
|
async getBalance(walletId) {
|
|
841
843
|
return this.http.get(`/wallets/${walletId}/balance`);
|
|
@@ -899,21 +901,33 @@ var WalletClient = class {
|
|
|
899
901
|
// Token Transfers
|
|
900
902
|
// ---------------------------------------------------------------------------
|
|
901
903
|
/**
|
|
902
|
-
* Transfer tokens from
|
|
904
|
+
* Transfer tokens from a CDP wallet to any address.
|
|
905
|
+
*
|
|
906
|
+
* Supports native ETH and ERC-20 tokens. The source wallet must be a CDP-managed wallet.
|
|
903
907
|
*
|
|
904
|
-
* @param request - Transfer details
|
|
908
|
+
* @param request - Transfer details (use wallet_id or from_address)
|
|
905
909
|
* @returns Transaction result with hash and status
|
|
906
910
|
*
|
|
907
911
|
* @example
|
|
908
912
|
* ```typescript
|
|
913
|
+
* // Transfer ETH using wallet_id
|
|
909
914
|
* const result = await client.wallets.transfer({
|
|
910
|
-
*
|
|
915
|
+
* wallet_id: 'd1096269-f986-4fa6-a1f5-1a29ef69f6e4',
|
|
911
916
|
* to_address: '0x456...',
|
|
912
|
-
* amount: '0.
|
|
917
|
+
* amount: '0.0001',
|
|
913
918
|
* token: 'ETH',
|
|
914
|
-
* network: 'base-
|
|
919
|
+
* network: 'base-mainnet',
|
|
915
920
|
* });
|
|
916
921
|
* console.log('TX Hash:', result.tx_hash);
|
|
922
|
+
*
|
|
923
|
+
* // Transfer using from_address
|
|
924
|
+
* const result2 = await client.wallets.transfer({
|
|
925
|
+
* from_address: '0xaA2e82E5fCF97003d409Bc90826F40cfc8F27510',
|
|
926
|
+
* to_address: '0x456...',
|
|
927
|
+
* amount: '0.0001',
|
|
928
|
+
* token: 'ETH',
|
|
929
|
+
* network: 'base-mainnet',
|
|
930
|
+
* });
|
|
917
931
|
* ```
|
|
918
932
|
*/
|
|
919
933
|
async transfer(request) {
|
|
@@ -982,6 +996,81 @@ var WalletClient = class {
|
|
|
982
996
|
`/wallets/${walletId}/transactions${query ? `?${query}` : ""}`
|
|
983
997
|
);
|
|
984
998
|
}
|
|
999
|
+
// ---------------------------------------------------------------------------
|
|
1000
|
+
// Token Management
|
|
1001
|
+
// ---------------------------------------------------------------------------
|
|
1002
|
+
/**
|
|
1003
|
+
* Register a custom token for the tenant.
|
|
1004
|
+
*
|
|
1005
|
+
* This allows tracking balances and enabling transfers for custom ERC-20 tokens.
|
|
1006
|
+
*
|
|
1007
|
+
* @param request - Token details including contract address, symbol, decimals
|
|
1008
|
+
* @returns The created token
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* ```typescript
|
|
1012
|
+
* const token = await client.wallets.createToken({
|
|
1013
|
+
* contract_address: '0x...',
|
|
1014
|
+
* network: 'base-mainnet',
|
|
1015
|
+
* symbol: 'wSOL',
|
|
1016
|
+
* name: 'Wrapped Solana',
|
|
1017
|
+
* decimals: 9,
|
|
1018
|
+
* });
|
|
1019
|
+
* ```
|
|
1020
|
+
*/
|
|
1021
|
+
async createToken(request) {
|
|
1022
|
+
return this.http.post("/tokens", request);
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* List all tokens available to the tenant.
|
|
1026
|
+
*
|
|
1027
|
+
* Returns both tenant-specific tokens and global tokens.
|
|
1028
|
+
*
|
|
1029
|
+
* @param options - Filter options
|
|
1030
|
+
*/
|
|
1031
|
+
async listTokens(options = {}) {
|
|
1032
|
+
const params = new URLSearchParams();
|
|
1033
|
+
if (options.network) params.set("network", options.network);
|
|
1034
|
+
if (options.include_global !== void 0) params.set("include_global", String(options.include_global));
|
|
1035
|
+
if (options.include_hidden !== void 0) params.set("include_hidden", String(options.include_hidden));
|
|
1036
|
+
const query = params.toString();
|
|
1037
|
+
return this.http.get(`/tokens${query ? `?${query}` : ""}`);
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* List global tokens (available to all tenants).
|
|
1041
|
+
*
|
|
1042
|
+
* These are well-known tokens like USDC, WETH, DAI, etc.
|
|
1043
|
+
*/
|
|
1044
|
+
async listGlobalTokens(network) {
|
|
1045
|
+
const params = network ? `?network=${network}` : "";
|
|
1046
|
+
return this.http.get(`/tokens/global${params}`);
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Get a specific token by ID.
|
|
1050
|
+
*/
|
|
1051
|
+
async getToken(tokenId) {
|
|
1052
|
+
return this.http.get(`/tokens/${tokenId}`);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Get a token by contract address and network.
|
|
1056
|
+
*/
|
|
1057
|
+
async getTokenByContract(contractAddress, network) {
|
|
1058
|
+
return this.http.get(
|
|
1059
|
+
`/tokens/by-contract/${contractAddress}?network=${encodeURIComponent(network)}`
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Update a custom token.
|
|
1064
|
+
*/
|
|
1065
|
+
async updateToken(tokenId, request) {
|
|
1066
|
+
return this.http.patch(`/tokens/${tokenId}`, request);
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Delete a custom token (soft delete).
|
|
1070
|
+
*/
|
|
1071
|
+
async deleteToken(tokenId) {
|
|
1072
|
+
return this.http.delete(`/tokens/${tokenId}`);
|
|
1073
|
+
}
|
|
985
1074
|
};
|
|
986
1075
|
|
|
987
1076
|
// src/users.ts
|
package/package.json
CHANGED