@rhinestone/sdk 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accounts → src/accounts}/index.d.ts +207 -207
- package/dist/{accounts → src/accounts}/index.d.ts.map +1 -1
- package/dist/{accounts → src/accounts}/index.js +44 -40
- package/dist/{accounts → src/accounts}/nexus.d.ts +304 -304
- package/dist/{accounts → src/accounts}/nexus.d.ts.map +1 -1
- package/dist/{accounts → src/accounts}/nexus.js +7 -7
- package/dist/src/accounts/safe.d.ts +15524 -0
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/safe.js +84 -9
- package/dist/{accounts → src/accounts}/utils.d.ts +1 -1
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/{execution → src/execution}/index.d.ts +1 -1
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/{execution → src/execution}/index.js +7 -8
- package/dist/{execution → src/execution}/smart-session.d.ts +2 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -0
- package/dist/{execution → src/execution}/smart-session.js +4 -6
- package/dist/{index.d.ts → src/index.d.ts} +9 -3
- package/dist/src/index.d.ts.map +1 -0
- package/dist/{index.js → src/index.js} +21 -1
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.d.ts +1 -1
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.js +16 -2
- package/dist/src/modules/omni-account.d.ts.map +1 -0
- package/dist/src/modules/validators/core.d.ts +23 -0
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/src/modules/validators/core.js +112 -0
- package/dist/src/modules/validators/index.d.ts +4 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/src/modules/validators/index.js +3 -0
- package/dist/{modules/validators.d.ts → src/modules/validators/smart-sessions.d.ts} +4 -6
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/{modules/validators.js → src/modules/validators/smart-sessions.js} +7 -115
- package/dist/{orchestrator → src/orchestrator}/client.d.ts +2 -1
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/client.js +19 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/index.d.ts +11 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/index.js +10 -0
- package/dist/{orchestrator → src/orchestrator}/registry.d.ts +5 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/registry.js +83 -2
- package/dist/{orchestrator → src/orchestrator}/types.d.ts +50 -2
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/utils.d.ts +6 -2
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/utils.js +76 -2
- package/dist/{types.d.ts → src/types.d.ts} +5 -4
- package/dist/src/types.d.ts.map +1 -0
- package/dist/test/modules/validators/smart-sessions.test.d.ts +2 -0
- package/dist/test/modules/validators/smart-sessions.test.d.ts.map +1 -0
- package/dist/test/modules/validators/smart-sessions.test.js +20 -0
- package/package.json +6 -2
- package/dist/accounts/safe.d.ts +0 -15
- package/dist/accounts/safe.d.ts.map +0 -1
- package/dist/accounts/utils.d.ts.map +0 -1
- package/dist/examples/abi/weth.d.ts +0 -214
- package/dist/examples/abi/weth.d.ts.map +0 -1
- package/dist/examples/abi/weth.js +0 -279
- package/dist/examples/cross-chain-ss.d.ts +0 -1
- package/dist/examples/cross-chain-ss.d.ts.map +0 -1
- package/dist/examples/cross-chain-ss.js +0 -171
- package/dist/examples/giza.d.ts +0 -1
- package/dist/examples/giza.d.ts.map +0 -1
- package/dist/examples/giza.js +0 -124
- package/dist/examples/omni-account.d.ts +0 -1
- package/dist/examples/omni-account.d.ts.map +0 -1
- package/dist/examples/omni-account.js +0 -169
- package/dist/examples/smart-sessions.d.ts +0 -1
- package/dist/examples/smart-sessions.d.ts.map +0 -1
- package/dist/examples/smart-sessions.js +0 -216
- package/dist/execution/index.d.ts.map +0 -1
- package/dist/execution/smart-session.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/modules/common.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/omni-account.d.ts.map +0 -1
- package/dist/modules/validators.d.ts.map +0 -1
- package/dist/orchestrator/client.d.ts.map +0 -1
- package/dist/orchestrator/consts.d.ts.map +0 -1
- package/dist/orchestrator/error.d.ts.map +0 -1
- package/dist/orchestrator/index.d.ts +0 -9
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/index.js +0 -10
- package/dist/orchestrator/registry.d.ts.map +0 -1
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/orchestrator/utils.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/{accounts → src/accounts}/utils.js +1 -1
- /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
- /package/dist/{modules → src/modules}/common.d.ts +0 -0
- /package/dist/{modules → src/modules}/common.js +0 -0
- /package/dist/{modules → src/modules}/omni-account.d.ts +0 -0
- /package/dist/{modules → src/modules}/omni-account.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/consts.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/consts.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/error.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/error.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/types.js +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
3
|
-
// import {
|
|
4
|
-
// baseSepolia,
|
|
5
|
-
// arbitrumSepolia,
|
|
6
|
-
// optimismSepolia,
|
|
7
|
-
// sepolia,
|
|
8
|
-
// optimism,
|
|
9
|
-
// base,
|
|
10
|
-
// arbitrum,
|
|
11
|
-
// } from 'viem/chains'
|
|
12
|
-
// import {
|
|
13
|
-
// Chain,
|
|
14
|
-
// createPublicClient,
|
|
15
|
-
// createWalletClient,
|
|
16
|
-
// encodeFunctionData,
|
|
17
|
-
// erc20Abi,
|
|
18
|
-
// getAbiItem,
|
|
19
|
-
// Hex,
|
|
20
|
-
// http,
|
|
21
|
-
// parseEther,
|
|
22
|
-
// toFunctionSelector,
|
|
23
|
-
// } from 'viem'
|
|
24
|
-
// import { createRhinestoneAccount } from '../index'
|
|
25
|
-
// import { Session } from '../types'
|
|
26
|
-
// const fundingPrivateKey = process.env.FUNDING_PRIVATE_KEY
|
|
27
|
-
// if (!fundingPrivateKey) {
|
|
28
|
-
// throw new Error('FUNDING_PRIVATE_KEY is not set')
|
|
29
|
-
// }
|
|
30
|
-
// const rhinestoneApiKey = process.env.RHINESTONE_API_KEY
|
|
31
|
-
// if (!rhinestoneApiKey) {
|
|
32
|
-
// throw new Error('RHINESTONE_API_KEY is not set')
|
|
33
|
-
// }
|
|
34
|
-
// const pimlicoApiKey = process.env.PIMLICO_API_KEY
|
|
35
|
-
// if (!pimlicoApiKey) {
|
|
36
|
-
// throw new Error('PIMLICO_API_KEY is not set')
|
|
37
|
-
// }
|
|
38
|
-
// const sourceChain = baseSepolia
|
|
39
|
-
// const targetChain = optimismSepolia
|
|
40
|
-
// const usdcTarget = getTokenAddress(targetChain)
|
|
41
|
-
// const usdcAmount = 1n
|
|
42
|
-
// const fundingAccount = privateKeyToAccount(fundingPrivateKey as Hex)
|
|
43
|
-
// const publicClient = createPublicClient({
|
|
44
|
-
// chain: sourceChain,
|
|
45
|
-
// transport: getTransport(sourceChain),
|
|
46
|
-
// })
|
|
47
|
-
// const fundingClient = createWalletClient({
|
|
48
|
-
// account: fundingAccount,
|
|
49
|
-
// chain: sourceChain,
|
|
50
|
-
// transport: getTransport(sourceChain),
|
|
51
|
-
// })
|
|
52
|
-
// const useNewKeys = true
|
|
53
|
-
// if (!useNewKeys) {
|
|
54
|
-
// console.log('new pks', [
|
|
55
|
-
// generatePrivateKey(),
|
|
56
|
-
// generatePrivateKey(),
|
|
57
|
-
// generatePrivateKey(),
|
|
58
|
-
// ])
|
|
59
|
-
// }
|
|
60
|
-
// const privateKeyA = useNewKeys
|
|
61
|
-
// ? generatePrivateKey()
|
|
62
|
-
// : '0x2abb7571751edee246e21179db22388dda1fd623e1aad66552f4a3838920eb3d'
|
|
63
|
-
// const accountA = privateKeyToAccount(privateKeyA)
|
|
64
|
-
// const privateKeyB = useNewKeys
|
|
65
|
-
// ? generatePrivateKey()
|
|
66
|
-
// : '0xd30440894e60fbc1d17d5967c476ab9128c19e186077c042c6d1de592075a0d9'
|
|
67
|
-
// const accountB = privateKeyToAccount(privateKeyB)
|
|
68
|
-
// const privateKeyC = useNewKeys
|
|
69
|
-
// ? generatePrivateKey()
|
|
70
|
-
// : '0xb63c74af219a3949cf95f5e3a3d20b0137425de053bb03e5cc0f46fe0d19f22f'
|
|
71
|
-
// const accountC = privateKeyToAccount(privateKeyC)
|
|
72
|
-
// const session: Session = {
|
|
73
|
-
// owners: {
|
|
74
|
-
// type: 'ecdsa',
|
|
75
|
-
// accounts: [accountA],
|
|
76
|
-
// },
|
|
77
|
-
// // actions: [],
|
|
78
|
-
// actions: [
|
|
79
|
-
// {
|
|
80
|
-
// target: usdcTarget,
|
|
81
|
-
// selector: toFunctionSelector(
|
|
82
|
-
// getAbiItem({
|
|
83
|
-
// abi: erc20Abi,
|
|
84
|
-
// name: 'transfer',
|
|
85
|
-
// }),
|
|
86
|
-
// ),
|
|
87
|
-
// },
|
|
88
|
-
// ],
|
|
89
|
-
// }
|
|
90
|
-
// const rhinestoneAccount = await createRhinestoneAccount({
|
|
91
|
-
// account: {
|
|
92
|
-
// type: 'nexus',
|
|
93
|
-
// },
|
|
94
|
-
// owners: {
|
|
95
|
-
// type: 'ecdsa',
|
|
96
|
-
// accounts: [accountA, accountB, accountC],
|
|
97
|
-
// threshold: 2,
|
|
98
|
-
// },
|
|
99
|
-
// sessions: [session],
|
|
100
|
-
// rhinestoneApiKey,
|
|
101
|
-
// deployerAccount: fundingAccount,
|
|
102
|
-
// bundler: {
|
|
103
|
-
// type: 'pimlico',
|
|
104
|
-
// apiKey: pimlicoApiKey,
|
|
105
|
-
// },
|
|
106
|
-
// })
|
|
107
|
-
// const address = await rhinestoneAccount.getAddress()
|
|
108
|
-
// console.log(address)
|
|
109
|
-
// // prefund
|
|
110
|
-
// const ethBalance = await publicClient.getBalance({
|
|
111
|
-
// address,
|
|
112
|
-
// })
|
|
113
|
-
// if (ethBalance < parseEther('0.001')) {
|
|
114
|
-
// const txHash = await fundingClient.sendTransaction({
|
|
115
|
-
// to: address,
|
|
116
|
-
// value: parseEther('0.001'),
|
|
117
|
-
// })
|
|
118
|
-
// await publicClient.waitForTransactionReceipt({ hash: txHash })
|
|
119
|
-
// }
|
|
120
|
-
// const transactionResult = await rhinestoneAccount.sendTransactions({
|
|
121
|
-
// sourceChain,
|
|
122
|
-
// targetChain,
|
|
123
|
-
// calls: [
|
|
124
|
-
// {
|
|
125
|
-
// to: usdcTarget,
|
|
126
|
-
// data: encodeFunctionData({
|
|
127
|
-
// abi: erc20Abi,
|
|
128
|
-
// functionName: 'transfer',
|
|
129
|
-
// args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', usdcAmount],
|
|
130
|
-
// }),
|
|
131
|
-
// },
|
|
132
|
-
// ],
|
|
133
|
-
// tokenRequests: [
|
|
134
|
-
// {
|
|
135
|
-
// address: usdcTarget,
|
|
136
|
-
// amount: usdcAmount,
|
|
137
|
-
// },
|
|
138
|
-
// ],
|
|
139
|
-
// signers: {
|
|
140
|
-
// type: 'session',
|
|
141
|
-
// session,
|
|
142
|
-
// },
|
|
143
|
-
// })
|
|
144
|
-
// const result = await rhinestoneAccount.waitForExecution(transactionResult)
|
|
145
|
-
// console.log('status', result)
|
|
146
|
-
// function getTokenAddress(chain: Chain) {
|
|
147
|
-
// switch (chain.id) {
|
|
148
|
-
// case sepolia.id:
|
|
149
|
-
// return '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'
|
|
150
|
-
// case baseSepolia.id:
|
|
151
|
-
// return '0x036cbd53842c5426634e7929541ec2318f3dcf7e'
|
|
152
|
-
// case arbitrumSepolia.id:
|
|
153
|
-
// return '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d'
|
|
154
|
-
// case optimismSepolia.id:
|
|
155
|
-
// return '0x5fd84259d66Cd46123540766Be93DFE6D43130D7'
|
|
156
|
-
// case base.id:
|
|
157
|
-
// return '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
|
|
158
|
-
// case arbitrum.id:
|
|
159
|
-
// return '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
|
|
160
|
-
// case optimism.id:
|
|
161
|
-
// return '0x0b2c639c533813f4aa9d7837caf62653d097ff85'
|
|
162
|
-
// default:
|
|
163
|
-
// throw new Error('Unsupported chain')
|
|
164
|
-
// }
|
|
165
|
-
// }
|
|
166
|
-
// function getTransport(chain: Chain) {
|
|
167
|
-
// if (chain.id === sepolia.id) {
|
|
168
|
-
// return http('https://ethereum-sepolia-rpc.publicnode.com')
|
|
169
|
-
// }
|
|
170
|
-
// return http()
|
|
171
|
-
// }
|
package/dist/examples/giza.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=giza.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"giza.d.ts","sourceRoot":"","sources":["../../examples/giza.ts"],"names":[],"mappings":""}
|
package/dist/examples/giza.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { baseSepolia } from 'viem/chains'
|
|
3
|
-
// import { createRhinestoneAccount } from '../index'
|
|
4
|
-
// import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
5
|
-
// import {
|
|
6
|
-
// createPublicClient,
|
|
7
|
-
// createWalletClient,
|
|
8
|
-
// encodeFunctionData,
|
|
9
|
-
// erc20Abi,
|
|
10
|
-
// http,
|
|
11
|
-
// parseEther,
|
|
12
|
-
// zeroAddress,
|
|
13
|
-
// } from 'viem'
|
|
14
|
-
// import { Session } from '../types'
|
|
15
|
-
// const rhinestoneApiKey = 'YOUR_RHINESTONE_API_KEY'
|
|
16
|
-
// const chain = baseSepolia
|
|
17
|
-
// const weth = '0x4200000000000000000000000000000000000006'
|
|
18
|
-
// const wethAmount = 1n
|
|
19
|
-
// const publicClient = createPublicClient({
|
|
20
|
-
// chain,
|
|
21
|
-
// transport: http(),
|
|
22
|
-
// })
|
|
23
|
-
// const fundingAccount = privateKeyToAccount('0x_YOUR_PRIVATE_KEY')
|
|
24
|
-
// const fundingClient = createWalletClient({
|
|
25
|
-
// account: fundingAccount,
|
|
26
|
-
// chain,
|
|
27
|
-
// transport: http(),
|
|
28
|
-
// })
|
|
29
|
-
// const fundingAccountBalance = await publicClient.getBalance({
|
|
30
|
-
// address: fundingAccount.address,
|
|
31
|
-
// })
|
|
32
|
-
// if (fundingAccountBalance === 0n) {
|
|
33
|
-
// throw new Error(
|
|
34
|
-
// `Please fund the account ${fundingAccount.address} with base sepolia ETH`,
|
|
35
|
-
// )
|
|
36
|
-
// }
|
|
37
|
-
// const ownerAccount = privateKeyToAccount(generatePrivateKey())
|
|
38
|
-
// const sessionSignerAccount = privateKeyToAccount(generatePrivateKey())
|
|
39
|
-
// const session: Session = {
|
|
40
|
-
// owners: {
|
|
41
|
-
// type: 'ecdsa',
|
|
42
|
-
// accounts: [sessionSignerAccount],
|
|
43
|
-
// },
|
|
44
|
-
// policies: [
|
|
45
|
-
// {
|
|
46
|
-
// type: 'time-frame',
|
|
47
|
-
// validAfter: Date.now() - 60, // 1 minute
|
|
48
|
-
// validUntil: Date.now() + 60 * 60 * 24, // 1 day
|
|
49
|
-
// },
|
|
50
|
-
// ],
|
|
51
|
-
// }
|
|
52
|
-
// const rhinestoneAccount = await createRhinestoneAccount({
|
|
53
|
-
// account: {
|
|
54
|
-
// type: 'nexus',
|
|
55
|
-
// },
|
|
56
|
-
// owners: {
|
|
57
|
-
// type: 'ecdsa',
|
|
58
|
-
// accounts: [ownerAccount],
|
|
59
|
-
// },
|
|
60
|
-
// sessions: [session],
|
|
61
|
-
// rhinestoneApiKey,
|
|
62
|
-
// deployerAccount: fundingAccount,
|
|
63
|
-
// bundler: {
|
|
64
|
-
// type: 'pimlico',
|
|
65
|
-
// apiKey: 'YOUR_PIMLICO_API_KEY',
|
|
66
|
-
// },
|
|
67
|
-
// })
|
|
68
|
-
// const address = await rhinestoneAccount.getAddress()
|
|
69
|
-
// console.log(`Smart account address: ${address}`)
|
|
70
|
-
// // Prefunding the smart account
|
|
71
|
-
// const ethBalance = await publicClient.getBalance({
|
|
72
|
-
// address,
|
|
73
|
-
// })
|
|
74
|
-
// if (ethBalance < parseEther('0.001')) {
|
|
75
|
-
// const txHash = await fundingClient.sendTransaction({
|
|
76
|
-
// to: address,
|
|
77
|
-
// value: parseEther('0.001'),
|
|
78
|
-
// })
|
|
79
|
-
// await publicClient.waitForTransactionReceipt({ hash: txHash })
|
|
80
|
-
// }
|
|
81
|
-
// const transactionResult = await rhinestoneAccount.sendTransactions({
|
|
82
|
-
// chain,
|
|
83
|
-
// calls: [
|
|
84
|
-
// {
|
|
85
|
-
// to: weth,
|
|
86
|
-
// data: encodeFunctionData({
|
|
87
|
-
// abi: [
|
|
88
|
-
// {
|
|
89
|
-
// constant: false,
|
|
90
|
-
// inputs: [],
|
|
91
|
-
// name: 'deposit',
|
|
92
|
-
// outputs: [],
|
|
93
|
-
// payable: true,
|
|
94
|
-
// stateMutability: 'payable',
|
|
95
|
-
// type: 'function',
|
|
96
|
-
// },
|
|
97
|
-
// ],
|
|
98
|
-
// functionName: 'deposit',
|
|
99
|
-
// args: [],
|
|
100
|
-
// }),
|
|
101
|
-
// value: wethAmount,
|
|
102
|
-
// },
|
|
103
|
-
// {
|
|
104
|
-
// to: weth,
|
|
105
|
-
// data: encodeFunctionData({
|
|
106
|
-
// abi: erc20Abi,
|
|
107
|
-
// functionName: 'transfer',
|
|
108
|
-
// args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', wethAmount],
|
|
109
|
-
// }),
|
|
110
|
-
// },
|
|
111
|
-
// ],
|
|
112
|
-
// tokenRequests: [
|
|
113
|
-
// {
|
|
114
|
-
// address: zeroAddress,
|
|
115
|
-
// amount: wethAmount,
|
|
116
|
-
// },
|
|
117
|
-
// ],
|
|
118
|
-
// signers: {
|
|
119
|
-
// type: 'session',
|
|
120
|
-
// session,
|
|
121
|
-
// },
|
|
122
|
-
// })
|
|
123
|
-
// const result = await rhinestoneAccount.waitForExecution(transactionResult)
|
|
124
|
-
// console.log('status', result)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=omni-account.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omni-account.d.ts","sourceRoot":"","sources":["../../examples/omni-account.ts"],"names":[],"mappings":""}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
3
|
-
// import {
|
|
4
|
-
// baseSepolia,
|
|
5
|
-
// arbitrumSepolia,
|
|
6
|
-
// optimismSepolia,
|
|
7
|
-
// arbitrum,
|
|
8
|
-
// base,
|
|
9
|
-
// optimism,
|
|
10
|
-
// sepolia,
|
|
11
|
-
// } from 'viem/chains'
|
|
12
|
-
// import {
|
|
13
|
-
// Chain,
|
|
14
|
-
// createPublicClient,
|
|
15
|
-
// createWalletClient,
|
|
16
|
-
// encodeFunctionData,
|
|
17
|
-
// erc20Abi,
|
|
18
|
-
// Hex,
|
|
19
|
-
// http,
|
|
20
|
-
// parseEther,
|
|
21
|
-
// parseUnits,
|
|
22
|
-
// } from 'viem'
|
|
23
|
-
// import { createRhinestoneAccount } from '../index'
|
|
24
|
-
// const fundingPrivateKey = process.env.FUNDING_PRIVATE_KEY
|
|
25
|
-
// if (!fundingPrivateKey) {
|
|
26
|
-
// throw new Error('FUNDING_PRIVATE_KEY is not set')
|
|
27
|
-
// }
|
|
28
|
-
// const rhinestoneApiKey = process.env.RHINESTONE_API_KEY
|
|
29
|
-
// if (!rhinestoneApiKey) {
|
|
30
|
-
// throw new Error('RHINESTONE_API_KEY is not set')
|
|
31
|
-
// }
|
|
32
|
-
// const sourceChain = baseSepolia
|
|
33
|
-
// const targetChain = arbitrumSepolia
|
|
34
|
-
// const usdcSource = getTokenAddress(sourceChain)
|
|
35
|
-
// const usdcTarget = getTokenAddress(targetChain)
|
|
36
|
-
// const usdcAmount = 1n
|
|
37
|
-
// const fundingAccount = privateKeyToAccount(fundingPrivateKey as Hex)
|
|
38
|
-
// const publicClient = createPublicClient({
|
|
39
|
-
// chain: sourceChain,
|
|
40
|
-
// transport: getTransport(sourceChain),
|
|
41
|
-
// })
|
|
42
|
-
// const publicTargetClient = createPublicClient({
|
|
43
|
-
// chain: targetChain,
|
|
44
|
-
// transport: getTransport(targetChain),
|
|
45
|
-
// })
|
|
46
|
-
// const fundingClient = createWalletClient({
|
|
47
|
-
// account: fundingAccount,
|
|
48
|
-
// chain: sourceChain,
|
|
49
|
-
// transport: getTransport(sourceChain),
|
|
50
|
-
// })
|
|
51
|
-
// const fundingTargetClient = createWalletClient({
|
|
52
|
-
// account: fundingAccount,
|
|
53
|
-
// chain: targetChain,
|
|
54
|
-
// transport: getTransport(targetChain),
|
|
55
|
-
// })
|
|
56
|
-
// const useNewKeys = true
|
|
57
|
-
// if (!useNewKeys) {
|
|
58
|
-
// console.log('new pks', [
|
|
59
|
-
// generatePrivateKey(),
|
|
60
|
-
// generatePrivateKey(),
|
|
61
|
-
// generatePrivateKey(),
|
|
62
|
-
// ])
|
|
63
|
-
// }
|
|
64
|
-
// const privateKeyA = useNewKeys
|
|
65
|
-
// ? generatePrivateKey()
|
|
66
|
-
// : '0xe4b8f59fa0999924cf05c7c81fe436de905c43d8c2ba1cb50b8695d6e830cb7a'
|
|
67
|
-
// const accountA = privateKeyToAccount(privateKeyA)
|
|
68
|
-
// const privateKeyB = useNewKeys
|
|
69
|
-
// ? generatePrivateKey()
|
|
70
|
-
// : '0x0b6d1278f1dce8419f99c72a0354f10a52dfe5bc65008f72b59c2fdb2731fae5'
|
|
71
|
-
// const accountB = privateKeyToAccount(privateKeyB)
|
|
72
|
-
// const privateKeyC = useNewKeys
|
|
73
|
-
// ? generatePrivateKey()
|
|
74
|
-
// : '0xc1a32b6410d65a2faf779dd809c3b91c35436c89f51ff7b5335e57ebf4c50dc5'
|
|
75
|
-
// const accountC = privateKeyToAccount(privateKeyC)
|
|
76
|
-
// const rhinestoneAccount = await createRhinestoneAccount({
|
|
77
|
-
// account: {
|
|
78
|
-
// type: 'nexus',
|
|
79
|
-
// },
|
|
80
|
-
// owners: {
|
|
81
|
-
// type: 'ecdsa',
|
|
82
|
-
// accounts: [accountA, accountB, accountC],
|
|
83
|
-
// threshold: 2,
|
|
84
|
-
// },
|
|
85
|
-
// rhinestoneApiKey,
|
|
86
|
-
// deployerAccount: fundingAccount,
|
|
87
|
-
// })
|
|
88
|
-
// const address = await rhinestoneAccount.getAddress()
|
|
89
|
-
// console.log(address)
|
|
90
|
-
// // prefund
|
|
91
|
-
// const ethBalance = await publicClient.getBalance({
|
|
92
|
-
// address,
|
|
93
|
-
// })
|
|
94
|
-
// if (ethBalance < parseEther('0.001')) {
|
|
95
|
-
// const txHash = await fundingClient.sendTransaction({
|
|
96
|
-
// to: address,
|
|
97
|
-
// value: parseEther('0.001'),
|
|
98
|
-
// })
|
|
99
|
-
// await publicClient.waitForTransactionReceipt({ hash: txHash })
|
|
100
|
-
// // const txHash2 = await fundingTargetClient.sendTransaction({
|
|
101
|
-
// // to: usdcTarget,
|
|
102
|
-
// // data: encodeFunctionData({
|
|
103
|
-
// // abi: erc20Abi,
|
|
104
|
-
// // functionName: 'transfer',
|
|
105
|
-
// // args: [address, parseUnits('0.2', 6)],
|
|
106
|
-
// // }),
|
|
107
|
-
// // })
|
|
108
|
-
// // console.log('txHash2', txHash2)
|
|
109
|
-
// // await publicTargetClient.waitForTransactionReceipt({ hash: txHash2 })
|
|
110
|
-
// const txHash2 = await fundingClient.sendTransaction({
|
|
111
|
-
// to: usdcSource,
|
|
112
|
-
// data: encodeFunctionData({
|
|
113
|
-
// abi: erc20Abi,
|
|
114
|
-
// functionName: 'transfer',
|
|
115
|
-
// args: [address, parseUnits('0.5', 6)],
|
|
116
|
-
// }),
|
|
117
|
-
// })
|
|
118
|
-
// await publicClient.waitForTransactionReceipt({ hash: txHash2 })
|
|
119
|
-
// }
|
|
120
|
-
// const transactionResult = await rhinestoneAccount.sendTransactions({
|
|
121
|
-
// sourceChain,
|
|
122
|
-
// targetChain,
|
|
123
|
-
// calls: [
|
|
124
|
-
// {
|
|
125
|
-
// to: usdcTarget,
|
|
126
|
-
// value: 0n,
|
|
127
|
-
// data: encodeFunctionData({
|
|
128
|
-
// abi: erc20Abi,
|
|
129
|
-
// functionName: 'transfer',
|
|
130
|
-
// args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', usdcAmount],
|
|
131
|
-
// }),
|
|
132
|
-
// },
|
|
133
|
-
// ],
|
|
134
|
-
// tokenRequests: [
|
|
135
|
-
// {
|
|
136
|
-
// address: usdcTarget,
|
|
137
|
-
// amount: usdcAmount,
|
|
138
|
-
// },
|
|
139
|
-
// ],
|
|
140
|
-
// })
|
|
141
|
-
// console.log('result', transactionResult)
|
|
142
|
-
// const result = await rhinestoneAccount.waitForExecution(transactionResult)
|
|
143
|
-
// console.log('status', result)
|
|
144
|
-
// function getTokenAddress(chain: Chain) {
|
|
145
|
-
// switch (chain.id) {
|
|
146
|
-
// case sepolia.id:
|
|
147
|
-
// return '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'
|
|
148
|
-
// case baseSepolia.id:
|
|
149
|
-
// return '0x036cbd53842c5426634e7929541ec2318f3dcf7e'
|
|
150
|
-
// case arbitrumSepolia.id:
|
|
151
|
-
// return '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d'
|
|
152
|
-
// case optimismSepolia.id:
|
|
153
|
-
// return '0x5fd84259d66Cd46123540766Be93DFE6D43130D7'
|
|
154
|
-
// case base.id:
|
|
155
|
-
// return '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
|
|
156
|
-
// case arbitrum.id:
|
|
157
|
-
// return '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
|
|
158
|
-
// case optimism.id:
|
|
159
|
-
// return '0x0b2c639c533813f4aa9d7837caf62653d097ff85'
|
|
160
|
-
// default:
|
|
161
|
-
// throw new Error('Unsupported chain')
|
|
162
|
-
// }
|
|
163
|
-
// }
|
|
164
|
-
// function getTransport(chain: Chain) {
|
|
165
|
-
// if (chain.id === sepolia.id) {
|
|
166
|
-
// return http('https://ethereum-sepolia-rpc.publicnode.com')
|
|
167
|
-
// }
|
|
168
|
-
// return http()
|
|
169
|
-
// }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=smart-sessions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../examples/smart-sessions.ts"],"names":[],"mappings":""}
|