@gitmyabi-stg/xusd 0.0.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/README.md +108 -0
- package/contracts/FiatTokenProxy.d.ts +311 -0
- package/contracts/FiatTokenProxy.js +328 -0
- package/contracts/FiatTokenProxy.ts +428 -0
- package/contracts/FiatTokenV1.d.ts +1622 -0
- package/contracts/FiatTokenV1.js +1659 -0
- package/contracts/FiatTokenV1.ts +2163 -0
- package/contracts/index.d.ts +4 -0
- package/contracts/index.js +10 -0
- package/contracts/index.ts +5 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/package.json +43 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiatTokenProxy = exports.FiatTokenProxyAbi = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* FiatTokenProxy ABI
|
|
7
|
+
*
|
|
8
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
9
|
+
*/
|
|
10
|
+
exports.FiatTokenProxyAbi = [
|
|
11
|
+
{
|
|
12
|
+
"constant": false,
|
|
13
|
+
"inputs": [
|
|
14
|
+
{
|
|
15
|
+
"name": "newImplementation",
|
|
16
|
+
"type": "address"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"name": "upgradeTo",
|
|
20
|
+
"outputs": [],
|
|
21
|
+
"payable": false,
|
|
22
|
+
"stateMutability": "nonpayable",
|
|
23
|
+
"type": "function"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"constant": false,
|
|
27
|
+
"inputs": [
|
|
28
|
+
{
|
|
29
|
+
"name": "newImplementation",
|
|
30
|
+
"type": "address"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "data",
|
|
34
|
+
"type": "bytes"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"name": "upgradeToAndCall",
|
|
38
|
+
"outputs": [],
|
|
39
|
+
"payable": true,
|
|
40
|
+
"stateMutability": "payable",
|
|
41
|
+
"type": "function"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"constant": true,
|
|
45
|
+
"inputs": [],
|
|
46
|
+
"name": "implementation",
|
|
47
|
+
"outputs": [
|
|
48
|
+
{
|
|
49
|
+
"name": "",
|
|
50
|
+
"type": "address"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"payable": false,
|
|
54
|
+
"stateMutability": "view",
|
|
55
|
+
"type": "function"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"constant": false,
|
|
59
|
+
"inputs": [
|
|
60
|
+
{
|
|
61
|
+
"name": "newAdmin",
|
|
62
|
+
"type": "address"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"name": "changeAdmin",
|
|
66
|
+
"outputs": [],
|
|
67
|
+
"payable": false,
|
|
68
|
+
"stateMutability": "nonpayable",
|
|
69
|
+
"type": "function"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"constant": true,
|
|
73
|
+
"inputs": [],
|
|
74
|
+
"name": "admin",
|
|
75
|
+
"outputs": [
|
|
76
|
+
{
|
|
77
|
+
"name": "",
|
|
78
|
+
"type": "address"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"payable": false,
|
|
82
|
+
"stateMutability": "view",
|
|
83
|
+
"type": "function"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"inputs": [
|
|
87
|
+
{
|
|
88
|
+
"name": "_implementation",
|
|
89
|
+
"type": "address"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"payable": false,
|
|
93
|
+
"stateMutability": "nonpayable",
|
|
94
|
+
"type": "constructor"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"payable": true,
|
|
98
|
+
"stateMutability": "payable",
|
|
99
|
+
"type": "fallback"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"anonymous": false,
|
|
103
|
+
"inputs": [
|
|
104
|
+
{
|
|
105
|
+
"indexed": false,
|
|
106
|
+
"name": "previousAdmin",
|
|
107
|
+
"type": "address"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"indexed": false,
|
|
111
|
+
"name": "newAdmin",
|
|
112
|
+
"type": "address"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"name": "AdminChanged",
|
|
116
|
+
"type": "event"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"anonymous": false,
|
|
120
|
+
"inputs": [
|
|
121
|
+
{
|
|
122
|
+
"indexed": false,
|
|
123
|
+
"name": "implementation",
|
|
124
|
+
"type": "address"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"name": "Upgraded",
|
|
128
|
+
"type": "event"
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
/**
|
|
132
|
+
* FiatTokenProxy Contract Class
|
|
133
|
+
*
|
|
134
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
139
|
+
* import { mainnet } from 'viem/chains';
|
|
140
|
+
* import { FiatTokenProxy } from 'FiatTokenProxy';
|
|
141
|
+
*
|
|
142
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
143
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
144
|
+
*
|
|
145
|
+
* const contract = new FiatTokenProxy('0x...', { publicClient, walletClient });
|
|
146
|
+
*
|
|
147
|
+
* // Read functions
|
|
148
|
+
* const result = await contract.balanceOf('0x...');
|
|
149
|
+
*
|
|
150
|
+
* // Write functions
|
|
151
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
152
|
+
*
|
|
153
|
+
* // Simulate transactions (dry-run)
|
|
154
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
155
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
156
|
+
*
|
|
157
|
+
* // Watch events
|
|
158
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
159
|
+
* console.log('Transfer event:', event);
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
class FiatTokenProxy {
|
|
164
|
+
constructor(address, clients) {
|
|
165
|
+
this.contractAddress = address;
|
|
166
|
+
this.publicClient = clients.publicClient;
|
|
167
|
+
this.contract = (0, viem_1.getContract)({
|
|
168
|
+
address,
|
|
169
|
+
abi: exports.FiatTokenProxyAbi,
|
|
170
|
+
client: {
|
|
171
|
+
public: clients.publicClient,
|
|
172
|
+
wallet: clients.walletClient,
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get the contract address
|
|
178
|
+
*/
|
|
179
|
+
get address() {
|
|
180
|
+
return this.contractAddress;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get the underlying viem contract instance.
|
|
184
|
+
*/
|
|
185
|
+
getContract() {
|
|
186
|
+
return this.contract;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* implementation
|
|
190
|
+
* view
|
|
191
|
+
*/
|
|
192
|
+
async implementation() {
|
|
193
|
+
return this.contract.read.implementation();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* admin
|
|
197
|
+
* view
|
|
198
|
+
*/
|
|
199
|
+
async admin() {
|
|
200
|
+
return this.contract.read.admin();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* upgradeTo
|
|
204
|
+
* nonpayable
|
|
205
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
206
|
+
*/
|
|
207
|
+
async upgradeTo(newImplementation, options) {
|
|
208
|
+
if (!this.contract.write) {
|
|
209
|
+
throw new Error('Wallet client is required for write operations');
|
|
210
|
+
}
|
|
211
|
+
return this.contract.write.upgradeTo([newImplementation], options);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* upgradeToAndCall
|
|
215
|
+
* payable
|
|
216
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
217
|
+
*/
|
|
218
|
+
async upgradeToAndCall(newImplementation, data, options) {
|
|
219
|
+
if (!this.contract.write) {
|
|
220
|
+
throw new Error('Wallet client is required for write operations');
|
|
221
|
+
}
|
|
222
|
+
return this.contract.write.upgradeToAndCall([newImplementation, data], options);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* changeAdmin
|
|
226
|
+
* nonpayable
|
|
227
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
228
|
+
*/
|
|
229
|
+
async changeAdmin(newAdmin, options) {
|
|
230
|
+
if (!this.contract.write) {
|
|
231
|
+
throw new Error('Wallet client is required for write operations');
|
|
232
|
+
}
|
|
233
|
+
return this.contract.write.changeAdmin([newAdmin], options);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
240
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
241
|
+
* console.log('Would succeed:', result.result);
|
|
242
|
+
*/
|
|
243
|
+
get simulate() {
|
|
244
|
+
const contract = this.contract;
|
|
245
|
+
if (!contract.simulate) {
|
|
246
|
+
throw new Error('Public client is required for simulation');
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
/**
|
|
250
|
+
* Simulate upgradeTo
|
|
251
|
+
* Returns gas estimate and result without sending transaction
|
|
252
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
253
|
+
*/
|
|
254
|
+
async upgradeTo(newImplementation, options) {
|
|
255
|
+
return contract.simulate.upgradeTo([newImplementation], options);
|
|
256
|
+
},
|
|
257
|
+
/**
|
|
258
|
+
* Simulate upgradeToAndCall
|
|
259
|
+
* Returns gas estimate and result without sending transaction
|
|
260
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
261
|
+
*/
|
|
262
|
+
async upgradeToAndCall(newImplementation, data, options) {
|
|
263
|
+
return contract.simulate.upgradeToAndCall([newImplementation, data], options);
|
|
264
|
+
},
|
|
265
|
+
/**
|
|
266
|
+
* Simulate changeAdmin
|
|
267
|
+
* Returns gas estimate and result without sending transaction
|
|
268
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
269
|
+
*/
|
|
270
|
+
async changeAdmin(newAdmin, options) {
|
|
271
|
+
return contract.simulate.changeAdmin([newAdmin], options);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Watch contract events
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // Watch all Transfer events
|
|
280
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
281
|
+
* console.log('Transfer:', event);
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* // Stop watching
|
|
285
|
+
* unwatch();
|
|
286
|
+
*/
|
|
287
|
+
get watch() {
|
|
288
|
+
return {
|
|
289
|
+
/**
|
|
290
|
+
* Watch AdminChanged events
|
|
291
|
+
* @param callback Function to call when event is emitted
|
|
292
|
+
* @param filter Optional filter for indexed parameters
|
|
293
|
+
* @returns Unwatch function to stop listening
|
|
294
|
+
*/
|
|
295
|
+
AdminChanged: (callback) => {
|
|
296
|
+
return this.publicClient.watchContractEvent({
|
|
297
|
+
address: this.contractAddress,
|
|
298
|
+
abi: exports.FiatTokenProxyAbi,
|
|
299
|
+
eventName: 'AdminChanged',
|
|
300
|
+
onLogs: (logs) => {
|
|
301
|
+
logs.forEach((log) => {
|
|
302
|
+
callback(log.args);
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* Watch Upgraded events
|
|
309
|
+
* @param callback Function to call when event is emitted
|
|
310
|
+
* @param filter Optional filter for indexed parameters
|
|
311
|
+
* @returns Unwatch function to stop listening
|
|
312
|
+
*/
|
|
313
|
+
Upgraded: (callback) => {
|
|
314
|
+
return this.publicClient.watchContractEvent({
|
|
315
|
+
address: this.contractAddress,
|
|
316
|
+
abi: exports.FiatTokenProxyAbi,
|
|
317
|
+
eventName: 'Upgraded',
|
|
318
|
+
onLogs: (logs) => {
|
|
319
|
+
logs.forEach((log) => {
|
|
320
|
+
callback(log.args);
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
exports.FiatTokenProxy = FiatTokenProxy;
|