@proofchain/sdk 2.10.0 → 2.11.1
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 +34 -15
- package/dist/index.d.ts +34 -15
- package/dist/index.js +67 -25
- package/dist/index.mjs +67 -25
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1630,6 +1630,25 @@ interface WalletCreationResult {
|
|
|
1630
1630
|
network?: string;
|
|
1631
1631
|
source: string;
|
|
1632
1632
|
}
|
|
1633
|
+
interface EnsureWalletResult {
|
|
1634
|
+
user_id: string;
|
|
1635
|
+
asset_wallet: {
|
|
1636
|
+
wallet_id: string;
|
|
1637
|
+
address: string;
|
|
1638
|
+
wallet_type: string;
|
|
1639
|
+
network: string;
|
|
1640
|
+
[key: string]: any;
|
|
1641
|
+
};
|
|
1642
|
+
smart_wallet: {
|
|
1643
|
+
wallet_id: string;
|
|
1644
|
+
address: string;
|
|
1645
|
+
wallet_type: string;
|
|
1646
|
+
network: string;
|
|
1647
|
+
[key: string]: any;
|
|
1648
|
+
};
|
|
1649
|
+
network: string;
|
|
1650
|
+
created: boolean;
|
|
1651
|
+
}
|
|
1633
1652
|
interface SetProfileRequest {
|
|
1634
1653
|
email?: string;
|
|
1635
1654
|
first_name?: string;
|
|
@@ -1720,33 +1739,33 @@ declare class EndUsersClient {
|
|
|
1720
1739
|
*/
|
|
1721
1740
|
registerWallet(externalId: string, request: RegisterWalletRequest): Promise<WalletCreationResult>;
|
|
1722
1741
|
/**
|
|
1723
|
-
* Ensure a user has
|
|
1742
|
+
* Ensure a user has dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1724
1743
|
*
|
|
1725
|
-
* This is the recommended way for frontend devs to guarantee
|
|
1726
|
-
*
|
|
1744
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1745
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1727
1746
|
* on-chain claims, token transfers).
|
|
1728
1747
|
*
|
|
1729
|
-
* If the user already has
|
|
1730
|
-
*
|
|
1748
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1749
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1750
|
+
* for gasless transactions) via the CDP SDK.
|
|
1731
1751
|
*
|
|
1732
1752
|
* @param externalId - The user's external ID
|
|
1733
|
-
* @param
|
|
1734
|
-
* @returns
|
|
1753
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1754
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1735
1755
|
*
|
|
1736
1756
|
* @example
|
|
1737
1757
|
* ```typescript
|
|
1738
1758
|
* // One-liner before any wallet-dependent operation
|
|
1739
|
-
* const
|
|
1740
|
-
* console.log(
|
|
1759
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1760
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1761
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1762
|
+
* console.log(result.created); // false if they already existed
|
|
1741
1763
|
*
|
|
1742
|
-
* // With
|
|
1743
|
-
* const
|
|
1744
|
-
* wallet_type: 'eoa',
|
|
1745
|
-
* network: 'base-mainnet',
|
|
1746
|
-
* });
|
|
1764
|
+
* // With specific network
|
|
1765
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1747
1766
|
* ```
|
|
1748
1767
|
*/
|
|
1749
|
-
ensureWallet(externalId: string,
|
|
1768
|
+
ensureWallet(externalId: string, network?: string): Promise<EnsureWalletResult>;
|
|
1750
1769
|
/**
|
|
1751
1770
|
* Update user attributes (convenience method) by external ID.
|
|
1752
1771
|
* Merges the provided attributes into the existing attributes object.
|
package/dist/index.d.ts
CHANGED
|
@@ -1630,6 +1630,25 @@ interface WalletCreationResult {
|
|
|
1630
1630
|
network?: string;
|
|
1631
1631
|
source: string;
|
|
1632
1632
|
}
|
|
1633
|
+
interface EnsureWalletResult {
|
|
1634
|
+
user_id: string;
|
|
1635
|
+
asset_wallet: {
|
|
1636
|
+
wallet_id: string;
|
|
1637
|
+
address: string;
|
|
1638
|
+
wallet_type: string;
|
|
1639
|
+
network: string;
|
|
1640
|
+
[key: string]: any;
|
|
1641
|
+
};
|
|
1642
|
+
smart_wallet: {
|
|
1643
|
+
wallet_id: string;
|
|
1644
|
+
address: string;
|
|
1645
|
+
wallet_type: string;
|
|
1646
|
+
network: string;
|
|
1647
|
+
[key: string]: any;
|
|
1648
|
+
};
|
|
1649
|
+
network: string;
|
|
1650
|
+
created: boolean;
|
|
1651
|
+
}
|
|
1633
1652
|
interface SetProfileRequest {
|
|
1634
1653
|
email?: string;
|
|
1635
1654
|
first_name?: string;
|
|
@@ -1720,33 +1739,33 @@ declare class EndUsersClient {
|
|
|
1720
1739
|
*/
|
|
1721
1740
|
registerWallet(externalId: string, request: RegisterWalletRequest): Promise<WalletCreationResult>;
|
|
1722
1741
|
/**
|
|
1723
|
-
* Ensure a user has
|
|
1742
|
+
* Ensure a user has dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1724
1743
|
*
|
|
1725
|
-
* This is the recommended way for frontend devs to guarantee
|
|
1726
|
-
*
|
|
1744
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1745
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1727
1746
|
* on-chain claims, token transfers).
|
|
1728
1747
|
*
|
|
1729
|
-
* If the user already has
|
|
1730
|
-
*
|
|
1748
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1749
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1750
|
+
* for gasless transactions) via the CDP SDK.
|
|
1731
1751
|
*
|
|
1732
1752
|
* @param externalId - The user's external ID
|
|
1733
|
-
* @param
|
|
1734
|
-
* @returns
|
|
1753
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1754
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1735
1755
|
*
|
|
1736
1756
|
* @example
|
|
1737
1757
|
* ```typescript
|
|
1738
1758
|
* // One-liner before any wallet-dependent operation
|
|
1739
|
-
* const
|
|
1740
|
-
* console.log(
|
|
1759
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1760
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1761
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1762
|
+
* console.log(result.created); // false if they already existed
|
|
1741
1763
|
*
|
|
1742
|
-
* // With
|
|
1743
|
-
* const
|
|
1744
|
-
* wallet_type: 'eoa',
|
|
1745
|
-
* network: 'base-mainnet',
|
|
1746
|
-
* });
|
|
1764
|
+
* // With specific network
|
|
1765
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1747
1766
|
* ```
|
|
1748
1767
|
*/
|
|
1749
|
-
ensureWallet(externalId: string,
|
|
1768
|
+
ensureWallet(externalId: string, network?: string): Promise<EnsureWalletResult>;
|
|
1750
1769
|
/**
|
|
1751
1770
|
* Update user attributes (convenience method) by external ID.
|
|
1752
1771
|
* Merges the provided attributes into the existing attributes object.
|
package/dist/index.js
CHANGED
|
@@ -1248,44 +1248,86 @@ var EndUsersClient = class {
|
|
|
1248
1248
|
return this.http.post(`/end-users/by-external/${encodeURIComponent(externalId)}/register-wallet`, request);
|
|
1249
1249
|
}
|
|
1250
1250
|
/**
|
|
1251
|
-
* Ensure a user has
|
|
1251
|
+
* Ensure a user has dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1252
1252
|
*
|
|
1253
|
-
* This is the recommended way for frontend devs to guarantee
|
|
1254
|
-
*
|
|
1253
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1254
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1255
1255
|
* on-chain claims, token transfers).
|
|
1256
1256
|
*
|
|
1257
|
-
* If the user already has
|
|
1258
|
-
*
|
|
1257
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1258
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1259
|
+
* for gasless transactions) via the CDP SDK.
|
|
1259
1260
|
*
|
|
1260
1261
|
* @param externalId - The user's external ID
|
|
1261
|
-
* @param
|
|
1262
|
-
* @returns
|
|
1262
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1263
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1263
1264
|
*
|
|
1264
1265
|
* @example
|
|
1265
1266
|
* ```typescript
|
|
1266
1267
|
* // One-liner before any wallet-dependent operation
|
|
1267
|
-
* const
|
|
1268
|
-
* console.log(
|
|
1268
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1269
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1270
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1271
|
+
* console.log(result.created); // false if they already existed
|
|
1269
1272
|
*
|
|
1270
|
-
* // With
|
|
1271
|
-
* const
|
|
1272
|
-
* wallet_type: 'eoa',
|
|
1273
|
-
* network: 'base-mainnet',
|
|
1274
|
-
* });
|
|
1273
|
+
* // With specific network
|
|
1274
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1275
1275
|
* ```
|
|
1276
1276
|
*/
|
|
1277
|
-
async ensureWallet(externalId,
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1277
|
+
async ensureWallet(externalId, network = "base-sepolia") {
|
|
1278
|
+
const existingWallets = await this.http.get(
|
|
1279
|
+
`/wallets/user/${encodeURIComponent(externalId)}`
|
|
1280
|
+
);
|
|
1281
|
+
if (existingWallets && existingWallets.length > 0) {
|
|
1282
|
+
const eoa = existingWallets.find((w) => w.wallet_type === "eoa");
|
|
1283
|
+
const smart = existingWallets.find((w) => w.wallet_type === "smart");
|
|
1284
|
+
if (eoa && smart) {
|
|
1285
|
+
return {
|
|
1286
|
+
user_id: externalId,
|
|
1287
|
+
asset_wallet: eoa,
|
|
1288
|
+
smart_wallet: smart,
|
|
1289
|
+
network: eoa.network,
|
|
1290
|
+
created: false
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
if (eoa && !smart) {
|
|
1294
|
+
const smartWallet = await this.http.post("/wallets", {
|
|
1295
|
+
user_id: externalId,
|
|
1296
|
+
wallet_type: "smart",
|
|
1297
|
+
network: eoa.network,
|
|
1298
|
+
metadata: { owner_wallet_id: eoa.wallet_id }
|
|
1299
|
+
});
|
|
1300
|
+
return {
|
|
1301
|
+
user_id: externalId,
|
|
1302
|
+
asset_wallet: eoa,
|
|
1303
|
+
smart_wallet: smartWallet,
|
|
1304
|
+
network: eoa.network,
|
|
1305
|
+
created: true
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
if (smart && !eoa) {
|
|
1309
|
+
const eoaWallet = await this.http.post("/wallets", {
|
|
1310
|
+
user_id: externalId,
|
|
1311
|
+
wallet_type: "eoa",
|
|
1312
|
+
network: smart.network
|
|
1313
|
+
});
|
|
1314
|
+
return {
|
|
1315
|
+
user_id: externalId,
|
|
1316
|
+
asset_wallet: eoaWallet,
|
|
1317
|
+
smart_wallet: smart,
|
|
1318
|
+
network: smart.network,
|
|
1319
|
+
created: true
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1287
1322
|
}
|
|
1288
|
-
|
|
1323
|
+
const dual = await this.http.post("/wallets/dual", {
|
|
1324
|
+
user_id: externalId,
|
|
1325
|
+
network
|
|
1326
|
+
});
|
|
1327
|
+
return {
|
|
1328
|
+
...dual,
|
|
1329
|
+
created: true
|
|
1330
|
+
};
|
|
1289
1331
|
}
|
|
1290
1332
|
/**
|
|
1291
1333
|
* Update user attributes (convenience method) by external ID.
|
package/dist/index.mjs
CHANGED
|
@@ -1194,44 +1194,86 @@ var EndUsersClient = class {
|
|
|
1194
1194
|
return this.http.post(`/end-users/by-external/${encodeURIComponent(externalId)}/register-wallet`, request);
|
|
1195
1195
|
}
|
|
1196
1196
|
/**
|
|
1197
|
-
* Ensure a user has
|
|
1197
|
+
* Ensure a user has dual wallets (EOA + Smart Account), creating them if they don't exist.
|
|
1198
1198
|
*
|
|
1199
|
-
* This is the recommended way for frontend devs to guarantee
|
|
1200
|
-
*
|
|
1199
|
+
* This is the recommended way for frontend devs to guarantee wallets exist
|
|
1200
|
+
* before performing any wallet-dependent operation (e.g. attestation,
|
|
1201
1201
|
* on-chain claims, token transfers).
|
|
1202
1202
|
*
|
|
1203
|
-
* If the user already has
|
|
1204
|
-
*
|
|
1203
|
+
* If the user already has both wallet types, returns them immediately.
|
|
1204
|
+
* If not, creates a dual wallet pair (EOA asset wallet + Smart Account
|
|
1205
|
+
* for gasless transactions) via the CDP SDK.
|
|
1205
1206
|
*
|
|
1206
1207
|
* @param externalId - The user's external ID
|
|
1207
|
-
* @param
|
|
1208
|
-
* @returns
|
|
1208
|
+
* @param network - Network to create wallets on (default: 'base-sepolia')
|
|
1209
|
+
* @returns EnsureWalletResult with both wallets and whether they were newly created
|
|
1209
1210
|
*
|
|
1210
1211
|
* @example
|
|
1211
1212
|
* ```typescript
|
|
1212
1213
|
* // One-liner before any wallet-dependent operation
|
|
1213
|
-
* const
|
|
1214
|
-
* console.log(
|
|
1214
|
+
* const result = await client.users.ensureWallet('user-123');
|
|
1215
|
+
* console.log(result.asset_wallet.address); // '0xabc...'
|
|
1216
|
+
* console.log(result.smart_wallet.address); // '0xdef...'
|
|
1217
|
+
* console.log(result.created); // false if they already existed
|
|
1215
1218
|
*
|
|
1216
|
-
* // With
|
|
1217
|
-
* const
|
|
1218
|
-
* wallet_type: 'eoa',
|
|
1219
|
-
* network: 'base-mainnet',
|
|
1220
|
-
* });
|
|
1219
|
+
* // With specific network
|
|
1220
|
+
* const result = await client.users.ensureWallet('user-123', 'base-mainnet');
|
|
1221
1221
|
* ```
|
|
1222
1222
|
*/
|
|
1223
|
-
async ensureWallet(externalId,
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1223
|
+
async ensureWallet(externalId, network = "base-sepolia") {
|
|
1224
|
+
const existingWallets = await this.http.get(
|
|
1225
|
+
`/wallets/user/${encodeURIComponent(externalId)}`
|
|
1226
|
+
);
|
|
1227
|
+
if (existingWallets && existingWallets.length > 0) {
|
|
1228
|
+
const eoa = existingWallets.find((w) => w.wallet_type === "eoa");
|
|
1229
|
+
const smart = existingWallets.find((w) => w.wallet_type === "smart");
|
|
1230
|
+
if (eoa && smart) {
|
|
1231
|
+
return {
|
|
1232
|
+
user_id: externalId,
|
|
1233
|
+
asset_wallet: eoa,
|
|
1234
|
+
smart_wallet: smart,
|
|
1235
|
+
network: eoa.network,
|
|
1236
|
+
created: false
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
if (eoa && !smart) {
|
|
1240
|
+
const smartWallet = await this.http.post("/wallets", {
|
|
1241
|
+
user_id: externalId,
|
|
1242
|
+
wallet_type: "smart",
|
|
1243
|
+
network: eoa.network,
|
|
1244
|
+
metadata: { owner_wallet_id: eoa.wallet_id }
|
|
1245
|
+
});
|
|
1246
|
+
return {
|
|
1247
|
+
user_id: externalId,
|
|
1248
|
+
asset_wallet: eoa,
|
|
1249
|
+
smart_wallet: smartWallet,
|
|
1250
|
+
network: eoa.network,
|
|
1251
|
+
created: true
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
if (smart && !eoa) {
|
|
1255
|
+
const eoaWallet = await this.http.post("/wallets", {
|
|
1256
|
+
user_id: externalId,
|
|
1257
|
+
wallet_type: "eoa",
|
|
1258
|
+
network: smart.network
|
|
1259
|
+
});
|
|
1260
|
+
return {
|
|
1261
|
+
user_id: externalId,
|
|
1262
|
+
asset_wallet: eoaWallet,
|
|
1263
|
+
smart_wallet: smart,
|
|
1264
|
+
network: smart.network,
|
|
1265
|
+
created: true
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1233
1268
|
}
|
|
1234
|
-
|
|
1269
|
+
const dual = await this.http.post("/wallets/dual", {
|
|
1270
|
+
user_id: externalId,
|
|
1271
|
+
network
|
|
1272
|
+
});
|
|
1273
|
+
return {
|
|
1274
|
+
...dual,
|
|
1275
|
+
created: true
|
|
1276
|
+
};
|
|
1235
1277
|
}
|
|
1236
1278
|
/**
|
|
1237
1279
|
* Update user attributes (convenience method) by external ID.
|
package/package.json
CHANGED