@rhinestone/sdk 0.3.0 → 0.4.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/examples/giza.d.ts +1 -0
- package/dist/examples/giza.d.ts.map +1 -0
- package/dist/examples/giza.js +124 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/validators.d.ts.map +1 -1
- package/dist/modules/validators.js +4 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=giza.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"giza.d.ts","sourceRoot":"","sources":["../../examples/giza.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,124 @@
|
|
|
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)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RhinestoneAccountConfig, Transaction } from './types';
|
|
1
|
+
import type { RhinestoneAccountConfig, Transaction, Session } from './types';
|
|
2
2
|
import { type TransactionResult } from './execution';
|
|
3
3
|
declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<{
|
|
4
4
|
config: RhinestoneAccountConfig;
|
|
@@ -19,4 +19,5 @@ declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promi
|
|
|
19
19
|
getAddress: () => Promise<`0x${string}`>;
|
|
20
20
|
}>;
|
|
21
21
|
export { createRhinestoneAccount };
|
|
22
|
+
export type { Session };
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,aAAa,CAAA;AAGpB,iBAAe,uBAAuB,CAAC,MAAM,EAAE,uBAAuB;;oCAC7B,WAAW;+BAIhB,iBAAiB;;;;;;;;;;;;;;GAcpD;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA;AAClC,YAAY,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../modules/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAOL,GAAG,EAKH,YAAY,EAKb,MAAM,MAAM,CAAA;AAEb,OAAO,EACL,QAAQ,EAER,uBAAuB,EACvB,OAAO,EAER,MAAM,UAAU,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AO,EAAE,OAAO;;;GAsBjE;AA6BD,iBAAe,+BAA+B,CAAC,KAAK,EAAE,KAAK;;;GAgB1D;AAyDD,iBAAS,wBAAwB,CAC/B,MAAM,EAAE,uBAAuB,GAC9B,MAAM,GAAG,IAAI,CAWf;AA6RD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,GAAG,oBAiClB;AAED,iBAAS,2BAA2B,CAClC,IAAI,EAAE,oBAAoB,EAC1B,YAAY,EAAE,GAAG,EACjB,SAAS,EAAE,GAAG,iBAcf;AAED,iBAAS,eAAe,CAAC,OAAO,EAAE,OAAO,iBAyBxC;AAED,iBAAS,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAUhD;AAED,iBAAe,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO;;;;;;GAoD3E;AAED,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gCAAgC,EAChC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,+BAA+B,GAChC,CAAA"}
|
|
@@ -289,7 +289,10 @@ function getPolicyData(policy) {
|
|
|
289
289
|
case 'time-frame': {
|
|
290
290
|
return {
|
|
291
291
|
policy: TIME_FRAME_POLICY_ADDRESS,
|
|
292
|
-
initData: encodePacked(['uint128', 'uint128'], [
|
|
292
|
+
initData: encodePacked(['uint128', 'uint128'], [
|
|
293
|
+
BigInt(policy.validUntil) / 1000n,
|
|
294
|
+
BigInt(policy.validAfter) / 1000n,
|
|
295
|
+
]),
|
|
293
296
|
};
|
|
294
297
|
}
|
|
295
298
|
case 'usage-limit': {
|
package/dist/types.d.ts
CHANGED