@atxp/base 0.9.0 → 0.9.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/basePaymentMaker.d.ts.map +1 -1
- package/dist/basePaymentMaker.js +33 -6
- package/dist/basePaymentMaker.js.map +1 -1
- package/dist/index.cjs +4833 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4836 -11
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@aa-sdk/core/dist/esm/client/schema.js +69 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/client/schema.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/base.js +43 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/base.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/client.js +22 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/errors/client.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/transport/split.js +57 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/transport/split.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/schema.js +33 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/schema.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/traceHeader.js +22 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/utils/traceHeader.js.map +1 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/version.js +6 -0
- package/dist/node_modules/@aa-sdk/core/dist/esm/version.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTrackerHeaders.js +36 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTrackerHeaders.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTransport.js +190 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/alchemyTransport.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/schema.js +10 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/schema.js.map +1 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/version.js +6 -0
- package/dist/node_modules/@account-kit/infra/dist/esm/version.js.map +1 -0
- package/dist/node_modules/zod/index.js +6 -0
- package/dist/node_modules/zod/index.js.map +1 -0
- package/dist/node_modules/zod/v3/ZodError.js +137 -0
- package/dist/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/zod/v3/errors.js +12 -0
- package/dist/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/zod/v3/external.js +7 -0
- package/dist/node_modules/zod/v3/external.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/parseUtil.js +113 -0
- package/dist/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/zod/v3/helpers/util.js +136 -0
- package/dist/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/zod/v3/locales/en.js +112 -0
- package/dist/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/zod/v3/types.js +3690 -0
- package/dist/node_modules/zod/v3/types.js.map +1 -0
- package/dist/smartWalletHelpers.d.ts +5 -1
- package/dist/smartWalletHelpers.d.ts.map +1 -1
- package/dist/smartWalletHelpers.js +67 -3
- package/dist/smartWalletHelpers.js.map +1 -1
- package/package.json +4 -3
|
@@ -7,7 +7,11 @@ export interface EphemeralSmartWallet {
|
|
|
7
7
|
signer: Account;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Creates an ephemeral smart wallet with paymaster support
|
|
10
|
+
* Creates an ephemeral smart wallet with paymaster support.
|
|
11
|
+
*
|
|
12
|
+
* Uses Alchemy infrastructure if ALCHEMY_API_KEY and ALCHEMY_GAS_POLICY_ID
|
|
13
|
+
* environment variables are set, otherwise falls back to Coinbase.
|
|
14
|
+
*
|
|
11
15
|
* @param privateKey - Private key for the wallet signer
|
|
12
16
|
* @param chainId - Chain ID (defaults to 8453 for Base mainnet, can be 84532 for Base Sepolia)
|
|
13
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartWalletHelpers.d.ts","sourceRoot":"","sources":["../src/smartWalletHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAId,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"smartWalletHelpers.d.ts","sourceRoot":"","sources":["../src/smartWalletHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAId,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAwDlC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;CACjB;AAmGD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,GAAG,EACf,OAAO,GAAE,MAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAK/B"}
|
|
@@ -2,6 +2,7 @@ import { createPublicClient, http } from 'viem';
|
|
|
2
2
|
import { base, baseSepolia } from 'viem/chains';
|
|
3
3
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
4
|
import { toCoinbaseSmartAccount, createBundlerClient } from 'viem/account-abstraction';
|
|
5
|
+
import { alchemy } from './node_modules/@account-kit/infra/dist/esm/alchemyTransport.js';
|
|
5
6
|
|
|
6
7
|
// Coinbase CDP API Key
|
|
7
8
|
const COINBASE_API_KEY = 'snPdXqIzOGhRkGNJvEHM5bl9Hm3yRO3m';
|
|
@@ -31,6 +32,13 @@ function getCoinbasePaymasterUrl(chainId) {
|
|
|
31
32
|
throw new Error(`Unsupported chain ID for Coinbase paymaster: ${chainId}`);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if Alchemy is configured via environment variables.
|
|
37
|
+
* Both ALCHEMY_API_KEY and ALCHEMY_GAS_POLICY_ID must be set.
|
|
38
|
+
*/
|
|
39
|
+
function isAlchemyConfigured() {
|
|
40
|
+
return !!(process.env.ALCHEMY_API_KEY && process.env.ALCHEMY_GAS_POLICY_ID);
|
|
41
|
+
}
|
|
34
42
|
/**
|
|
35
43
|
* Get Base chain configuration by chain ID
|
|
36
44
|
*/
|
|
@@ -45,11 +53,52 @@ function getBaseChain(chainId) {
|
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
/**
|
|
48
|
-
* Creates an ephemeral smart wallet with paymaster support
|
|
56
|
+
* Creates an ephemeral smart wallet with paymaster support using Alchemy infrastructure.
|
|
57
|
+
* Uses the official @account-kit/infra transport for proper Alchemy integration.
|
|
49
58
|
* @param privateKey - Private key for the wallet signer
|
|
50
59
|
* @param chainId - Chain ID (defaults to 8453 for Base mainnet, can be 84532 for Base Sepolia)
|
|
51
60
|
*/
|
|
52
|
-
async function
|
|
61
|
+
async function toEphemeralSmartWalletAlchemy(privateKey, chainId = base.id) {
|
|
62
|
+
const alchemyApiKey = process.env.ALCHEMY_API_KEY;
|
|
63
|
+
const alchemyPolicyId = process.env.ALCHEMY_GAS_POLICY_ID;
|
|
64
|
+
const signer = privateKeyToAccount(privateKey);
|
|
65
|
+
const chain = getBaseChain(chainId);
|
|
66
|
+
// Use the official Alchemy transport from @account-kit/infra
|
|
67
|
+
const alchemyTransport = alchemy({ apiKey: alchemyApiKey });
|
|
68
|
+
const publicClient = createPublicClient({
|
|
69
|
+
chain,
|
|
70
|
+
transport: alchemyTransport
|
|
71
|
+
});
|
|
72
|
+
// Create the Coinbase smart wallet (works with any ERC-4337 bundler)
|
|
73
|
+
const account = await toCoinbaseSmartAccount({
|
|
74
|
+
client: publicClient,
|
|
75
|
+
owners: [signer],
|
|
76
|
+
version: '1'
|
|
77
|
+
});
|
|
78
|
+
// Create bundler client with Alchemy paymaster support
|
|
79
|
+
const bundlerClient = createBundlerClient({
|
|
80
|
+
account,
|
|
81
|
+
client: publicClient,
|
|
82
|
+
transport: alchemyTransport,
|
|
83
|
+
chain,
|
|
84
|
+
paymaster: true,
|
|
85
|
+
paymasterContext: {
|
|
86
|
+
policyId: alchemyPolicyId
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
address: account.address,
|
|
91
|
+
client: bundlerClient,
|
|
92
|
+
account,
|
|
93
|
+
signer,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates an ephemeral smart wallet with paymaster support using Coinbase infrastructure.
|
|
98
|
+
* @param privateKey - Private key for the wallet signer
|
|
99
|
+
* @param chainId - Chain ID (defaults to 8453 for Base mainnet, can be 84532 for Base Sepolia)
|
|
100
|
+
*/
|
|
101
|
+
async function toEphemeralSmartWalletCoinbase(privateKey, chainId = base.id) {
|
|
53
102
|
const apiKey = COINBASE_API_KEY;
|
|
54
103
|
const signer = privateKeyToAccount(privateKey);
|
|
55
104
|
const chain = getBaseChain(chainId);
|
|
@@ -71,7 +120,7 @@ async function toEphemeralSmartWallet(privateKey, chainId = base.id) {
|
|
|
71
120
|
client: publicClient,
|
|
72
121
|
transport: http(`${bundlerUrl}/${apiKey}`),
|
|
73
122
|
chain,
|
|
74
|
-
paymaster: true,
|
|
123
|
+
paymaster: true,
|
|
75
124
|
paymasterContext: {
|
|
76
125
|
transport: http(`${paymasterUrl}/${apiKey}`)
|
|
77
126
|
}
|
|
@@ -83,6 +132,21 @@ async function toEphemeralSmartWallet(privateKey, chainId = base.id) {
|
|
|
83
132
|
signer,
|
|
84
133
|
};
|
|
85
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Creates an ephemeral smart wallet with paymaster support.
|
|
137
|
+
*
|
|
138
|
+
* Uses Alchemy infrastructure if ALCHEMY_API_KEY and ALCHEMY_GAS_POLICY_ID
|
|
139
|
+
* environment variables are set, otherwise falls back to Coinbase.
|
|
140
|
+
*
|
|
141
|
+
* @param privateKey - Private key for the wallet signer
|
|
142
|
+
* @param chainId - Chain ID (defaults to 8453 for Base mainnet, can be 84532 for Base Sepolia)
|
|
143
|
+
*/
|
|
144
|
+
async function toEphemeralSmartWallet(privateKey, chainId = base.id) {
|
|
145
|
+
if (isAlchemyConfigured()) {
|
|
146
|
+
return toEphemeralSmartWalletAlchemy(privateKey, chainId);
|
|
147
|
+
}
|
|
148
|
+
return toEphemeralSmartWalletCoinbase(privateKey, chainId);
|
|
149
|
+
}
|
|
86
150
|
|
|
87
151
|
export { toEphemeralSmartWallet };
|
|
88
152
|
//# sourceMappingURL=smartWalletHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartWalletHelpers.js","sources":["../src/smartWalletHelpers.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartWalletHelpers.js","sources":["../src/smartWalletHelpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAkBA;AACA,MAAM,gBAAgB,GAAG,kCAAkC;AAE3D;;AAEG;AACH,SAAS,qBAAqB,CAAC,OAAe,EAAA;IAC5C,QAAQ,OAAO;QACb,KAAK,IAAI;AACP,YAAA,OAAO,gDAAgD;QACzD,KAAK,KAAK;AACR,YAAA,OAAO,wDAAwD;AACjE,QAAA;AACE,YAAA,MAAM,IAAI,KAAK,CAAC,8CAA8C,OAAO,CAAA,CAAE,CAAC;;AAE9E;AAEA;;AAEG;AACH,SAAS,uBAAuB,CAAC,OAAe,EAAA;IAC9C,QAAQ,OAAO;QACb,KAAK,IAAI;AACP,YAAA,OAAO,gDAAgD;QACzD,KAAK,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,CAAA,EAAI,MAAM,EAAE;AAC5C;AACF,KAAA,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;AACxB,QAAA,MAAM,EAAE,aAAa;QACrB,OAAO;QACP,MAAM;KACP;AACH;AAEA;;;;;;;;AAQG;AACI,eAAe,sBAAsB,CAC1C,UAAe,EACf,OAAA,GAAkB,IAAI,CAAC,EAAE,EAAA;IAEzB,IAAI,mBAAmB,EAAE,EAAE;AACzB,QAAA,OAAO,6BAA6B,CAAC,UAAU,EAAE,OAAO,CAAC;IAC3D;AACA,IAAA,OAAO,8BAA8B,CAAC,UAAU,EAAE,OAAO,CAAC;AAC5D;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atxp/base",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "ATXP for Base Mini Apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
"pack:dry": "npm pack --dry-run"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@atxp/
|
|
36
|
+
"@account-kit/infra": "^4.81.3",
|
|
37
|
+
"@atxp/client": "0.9.1",
|
|
38
|
+
"@atxp/common": "0.9.1",
|
|
38
39
|
"bignumber.js": "^9.3.0",
|
|
39
40
|
"viem": "^2.34.0"
|
|
40
41
|
},
|