@nevermined-io/core-kit 0.1.1 → 0.1.3
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/package.json +1 -1
- package/dist/Instantiable.abstract.d.ts +0 -33
- package/dist/Instantiable.abstract.d.ts.map +0 -1
- package/dist/Instantiable.abstract.js +0 -98
- package/dist/artifacts/generated.d.ts +0 -39371
- package/dist/artifacts/generated.d.ts.map +0 -1
- package/dist/artifacts/generated.js +0 -21448
- package/dist/contracts/AccessManager.d.ts +0 -17
- package/dist/contracts/AccessManager.d.ts.map +0 -1
- package/dist/contracts/AccessManager.js +0 -15
- package/dist/contracts/AssetRegistry.d.ts +0 -105
- package/dist/contracts/AssetRegistry.d.ts.map +0 -1
- package/dist/contracts/AssetRegistry.js +0 -155
- package/dist/contracts/ContractBase.d.ts +0 -33
- package/dist/contracts/ContractBase.d.ts.map +0 -1
- package/dist/contracts/ContractBase.js +0 -413
- package/dist/contracts/ContractsApi.d.ts +0 -69
- package/dist/contracts/ContractsApi.d.ts.map +0 -1
- package/dist/contracts/ContractsApi.js +0 -73
- package/dist/contracts/FiatPaymentTemplate.d.ts +0 -10
- package/dist/contracts/FiatPaymentTemplate.d.ts.map +0 -1
- package/dist/contracts/FiatPaymentTemplate.js +0 -14
- package/dist/contracts/FiatSettlementCondition.d.ts +0 -11
- package/dist/contracts/FiatSettlementCondition.d.ts.map +0 -1
- package/dist/contracts/FiatSettlementCondition.js +0 -18
- package/dist/contracts/FixedPaymentTemplate.d.ts +0 -14
- package/dist/contracts/FixedPaymentTemplate.d.ts.map +0 -1
- package/dist/contracts/FixedPaymentTemplate.js +0 -63
- package/dist/contracts/NFT1155Base.d.ts +0 -50
- package/dist/contracts/NFT1155Base.d.ts.map +0 -1
- package/dist/contracts/NFT1155Base.js +0 -24
- package/dist/contracts/NFT1155Credits.d.ts +0 -6
- package/dist/contracts/NFT1155Credits.d.ts.map +0 -1
- package/dist/contracts/NFT1155Credits.js +0 -9
- package/dist/contracts/NFT1155ExpirableCredits.d.ts +0 -34
- package/dist/contracts/NFT1155ExpirableCredits.d.ts.map +0 -1
- package/dist/contracts/NFT1155ExpirableCredits.js +0 -18
- package/dist/contracts/NVMConfig.d.ts +0 -10
- package/dist/contracts/NVMConfig.d.ts.map +0 -1
- package/dist/contracts/NVMConfig.js +0 -18
- package/dist/contracts/PayAsYouGoTemplate.d.ts +0 -13
- package/dist/contracts/PayAsYouGoTemplate.d.ts.map +0 -1
- package/dist/contracts/PayAsYouGoTemplate.js +0 -59
- package/dist/contracts/ProtocolStandardFees.d.ts +0 -9
- package/dist/contracts/ProtocolStandardFees.d.ts.map +0 -1
- package/dist/contracts/ProtocolStandardFees.js +0 -15
- package/dist/contracts/Roles.d.ts +0 -13
- package/dist/contracts/Roles.d.ts.map +0 -1
- package/dist/contracts/Roles.js +0 -12
- package/dist/contracts/index.d.ts +0 -3
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -2
- package/dist/errors/NeverminedErrors.d.ts +0 -74
- package/dist/errors/NeverminedErrors.d.ts.map +0 -1
- package/dist/errors/NeverminedErrors.js +0 -128
- package/dist/errors/index.d.ts +0 -2
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/models/AgentAccessToken.d.ts +0 -123
- package/dist/models/AgentAccessToken.d.ts.map +0 -1
- package/dist/models/AgentAccessToken.js +0 -164
- package/dist/models/AgentX402AccessToken.d.ts +0 -59
- package/dist/models/AgentX402AccessToken.d.ts.map +0 -1
- package/dist/models/AgentX402AccessToken.js +0 -78
- package/dist/models/Logger.d.ts +0 -9
- package/dist/models/Logger.d.ts.map +0 -1
- package/dist/models/Logger.js +0 -27
- package/dist/models/NeverminedOptions.d.ts +0 -30
- package/dist/models/NeverminedOptions.d.ts.map +0 -1
- package/dist/models/NeverminedOptions.js +0 -28
- package/dist/models/NvmApiKey.d.ts +0 -137
- package/dist/models/NvmApiKey.d.ts.map +0 -1
- package/dist/models/NvmApiKey.js +0 -235
- package/dist/models/Transactions.d.ts +0 -11
- package/dist/models/Transactions.d.ts.map +0 -1
- package/dist/models/Transactions.js +0 -1
- package/dist/models/index.d.ts +0 -7
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -6
- package/dist/nevermined/Nevermined.d.ts +0 -48
- package/dist/nevermined/Nevermined.d.ts.map +0 -1
- package/dist/nevermined/Nevermined.js +0 -72
- package/dist/nevermined/api/PaymentsApi.d.ts +0 -25
- package/dist/nevermined/api/PaymentsApi.d.ts.map +0 -1
- package/dist/nevermined/api/PaymentsApi.js +0 -177
- package/dist/nevermined/api/ServicesApi.d.ts +0 -23
- package/dist/nevermined/api/ServicesApi.d.ts.map +0 -1
- package/dist/nevermined/api/ServicesApi.js +0 -27
- package/dist/nevermined/api/UtilsApi.d.ts +0 -28
- package/dist/nevermined/api/UtilsApi.d.ts.map +0 -1
- package/dist/nevermined/api/UtilsApi.js +0 -33
- package/dist/nevermined/index.d.ts +0 -3
- package/dist/nevermined/index.d.ts.map +0 -1
- package/dist/nevermined/index.js +0 -2
- package/dist/nevermined/utils/AgentUtils.d.ts +0 -8
- package/dist/nevermined/utils/AgentUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/AgentUtils.js +0 -56
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +0 -280
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/BlockchainViemUtils.js +0 -408
- package/dist/nevermined/utils/JwtUtils.d.ts +0 -27
- package/dist/nevermined/utils/JwtUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/JwtUtils.js +0 -161
- package/dist/nevermined/utils/SignatureUtils.d.ts +0 -14
- package/dist/nevermined/utils/SignatureUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/SignatureUtils.js +0 -99
- package/dist/nevermined/utils/WebServiceConnector.d.ts +0 -30
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +0 -1
- package/dist/nevermined/utils/WebServiceConnector.js +0 -170
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts +0 -36
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +0 -1
- package/dist/nevermined/utils/ZeroDevPolicies.js +0 -152
- package/dist/nevermined/utils/index.d.ts +0 -7
- package/dist/nevermined/utils/index.d.ts.map +0 -1
- package/dist/nevermined/utils/index.js +0 -6
- package/dist/services/Api.d.ts +0 -7
- package/dist/services/Api.d.ts.map +0 -1
- package/dist/services/Api.js +0 -25
- package/dist/services/Profiles.d.ts +0 -16
- package/dist/services/Profiles.d.ts.map +0 -1
- package/dist/services/Profiles.js +0 -84
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -2
- package/dist/utils/ConversionTypeHelpers.d.ts +0 -5
- package/dist/utils/ConversionTypeHelpers.d.ts.map +0 -1
- package/dist/utils/ConversionTypeHelpers.js +0 -30
- package/dist/utils/Network.d.ts +0 -5
- package/dist/utils/Network.d.ts.map +0 -1
- package/dist/utils/Network.js +0 -224
- package/dist/utils/helpers.d.ts +0 -23
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js +0 -161
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -3
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk';
|
|
2
|
-
import { BaseError, ContractFunctionRevertedError, encodeFunctionData, getContract, http, parseAbi, parseEventLogs, } from 'viem';
|
|
3
|
-
import { ContractsError, ContractSimulationError } from '../errors/index.js';
|
|
4
|
-
import { Instantiable } from '../Instantiable.abstract.js';
|
|
5
|
-
import { getInputsOfFunctionFormatted, getTransactionReceipt } from '../nevermined/index.js';
|
|
6
|
-
import { getChain } from '../utils/Network.js';
|
|
7
|
-
export class ContractBase extends Instantiable {
|
|
8
|
-
contractName;
|
|
9
|
-
contract;
|
|
10
|
-
address;
|
|
11
|
-
constructor(contractName, address) {
|
|
12
|
-
super();
|
|
13
|
-
this.contractName = contractName;
|
|
14
|
-
this.address = address;
|
|
15
|
-
}
|
|
16
|
-
async init(config, contractConfig) {
|
|
17
|
-
this.setInstanceConfig(config);
|
|
18
|
-
this.address = contractConfig.address;
|
|
19
|
-
this.contract = getContract({
|
|
20
|
-
address: contractConfig.address,
|
|
21
|
-
abi: contractConfig.abi,
|
|
22
|
-
client: { public: this.publicClient, wallet: this.walletClient },
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
async call(functionName, args, from) {
|
|
26
|
-
try {
|
|
27
|
-
return (await this.client.public.readContract({
|
|
28
|
-
address: this.address,
|
|
29
|
-
abi: this.contract.abi,
|
|
30
|
-
functionName: parseAbi([functionName]),
|
|
31
|
-
args,
|
|
32
|
-
...(from && { account: from }),
|
|
33
|
-
}));
|
|
34
|
-
//return await this.contract[functionSignature](...args, { from })
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
throw new ContractsError(`Calling method "${functionName}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async getTransactionReceipt(txHash) {
|
|
41
|
-
// Get the transaction receipt depending on the type of txHash
|
|
42
|
-
if ('transactionHash' in txHash) {
|
|
43
|
-
// txHash is TransactionReceipt
|
|
44
|
-
return txHash;
|
|
45
|
-
}
|
|
46
|
-
else if ('userOpHash' in txHash) {
|
|
47
|
-
// txHash is UserOperationReceipt, fetch the actual receipt using the utility function with retry logic
|
|
48
|
-
const hash = txHash.receipt.transactionHash;
|
|
49
|
-
return await getTransactionReceipt({
|
|
50
|
-
txHash: hash,
|
|
51
|
-
publicClient: this.client.public,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
throw new Error('Unknown transaction type');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
getTransactionLogs(txReceipt, eventName) {
|
|
59
|
-
return parseEventLogs({
|
|
60
|
-
abi: this.contract.abi,
|
|
61
|
-
logs: txReceipt.logs,
|
|
62
|
-
eventName,
|
|
63
|
-
strict: false,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
async multicall(calls, from, params = {}) {
|
|
67
|
-
if (from.type === 'local') {
|
|
68
|
-
this.logger.debug(`Blockchain Multicall using Local account`);
|
|
69
|
-
return await this.localAccountMulticall(calls, from, params, params.progress);
|
|
70
|
-
}
|
|
71
|
-
else if (from.type === 'json-rpc') {
|
|
72
|
-
this.logger.debug(`Blockchain Multicall using JSON-RPC account`);
|
|
73
|
-
return await this.localAccountMulticall(calls, from, params, params.progress);
|
|
74
|
-
}
|
|
75
|
-
else if (from.type === 'smart') {
|
|
76
|
-
this.logger.debug(`Blockchain Multicall using ZeroDev account`);
|
|
77
|
-
return await this.internalMulticallSmartAccount(calls, from, params, params.progress);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
throw new ContractsError(`Account not supported`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async simulate(functionName, from, args, params = {}) {
|
|
84
|
-
if (from.type === 'local') {
|
|
85
|
-
this.logger.debug(`Simulating call to: ${functionName} and following args: ${args}`);
|
|
86
|
-
return await this.localAccountSimulate(functionName, from, args, params);
|
|
87
|
-
}
|
|
88
|
-
else if (from.type === 'json-rpc') {
|
|
89
|
-
this.logger.debug(`Simulating call to: ${functionName} and following args: ${args}`);
|
|
90
|
-
return await this.localAccountSimulate(functionName, from, args, params);
|
|
91
|
-
}
|
|
92
|
-
else if (from.type === 'smart') {
|
|
93
|
-
this.logger.debug(`Simulating call to: ${functionName} and following args: ${args}`);
|
|
94
|
-
return await this.internalSimulateSmartAccount(functionName, from, args, params);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
throw new ContractsError(`Account not supported`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async send(functionName, from, args, params = {}) {
|
|
101
|
-
if (from.type === 'local') {
|
|
102
|
-
this.logger.debug(`Blockchain Send using Local account with functionName: ${functionName} and following args: ${args}`);
|
|
103
|
-
return await this.localAccountSend(functionName, from, args, params, params.progress);
|
|
104
|
-
}
|
|
105
|
-
else if (from.type === 'json-rpc') {
|
|
106
|
-
this.logger.debug(`Blockchain Send using JSON-RPC account to ${functionName}`);
|
|
107
|
-
return await this.localAccountSend(functionName, from, args, params, params.progress);
|
|
108
|
-
}
|
|
109
|
-
else if (from.type === 'smart') {
|
|
110
|
-
this.logger.debug(`Blockchain Send using ZeroDev account`);
|
|
111
|
-
return await this.internalSendSmartAccount(functionName, from, args, params, params.progress);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
throw new ContractsError(`Account not supported`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
async internalMulticallSmartAccount(calls, from, txparams, progress) {
|
|
118
|
-
if (progress) {
|
|
119
|
-
progress({
|
|
120
|
-
stage: 'multicall-sending',
|
|
121
|
-
args: [],
|
|
122
|
-
method: '',
|
|
123
|
-
from: from,
|
|
124
|
-
contractAddress: this.address,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
const ZERODEV_RPC = `https://rpc.zerodev.app/api/v3/${this.config.zeroDevProjectId}/chain/${this.config.chainId}`;
|
|
128
|
-
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
129
|
-
chain: getChain(this.config.chainId),
|
|
130
|
-
transport: http(ZERODEV_RPC),
|
|
131
|
-
});
|
|
132
|
-
const kernelClient = createKernelAccountClient({
|
|
133
|
-
account: from,
|
|
134
|
-
chain: getChain(this.config.chainId),
|
|
135
|
-
bundlerTransport: http(ZERODEV_RPC),
|
|
136
|
-
client: this.contract.publicClient,
|
|
137
|
-
paymaster: {
|
|
138
|
-
getPaymasterData: (userOperation) => {
|
|
139
|
-
return zerodevPaymaster.sponsorUserOperation({
|
|
140
|
-
userOperation,
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
const encodedCalls = [];
|
|
146
|
-
calls.map((call) => {
|
|
147
|
-
encodedCalls.push({
|
|
148
|
-
to: call.contractAddress || this.address,
|
|
149
|
-
value: txparams.value || 0n,
|
|
150
|
-
data: encodeFunctionData({
|
|
151
|
-
abi: call.abi,
|
|
152
|
-
functionName: call.functionName,
|
|
153
|
-
args: call.args,
|
|
154
|
-
}),
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
try {
|
|
158
|
-
const userOpHash = await kernelClient.sendUserOperation({
|
|
159
|
-
callData: await kernelClient.account.encodeCalls(encodedCalls),
|
|
160
|
-
});
|
|
161
|
-
if (progress) {
|
|
162
|
-
progress({
|
|
163
|
-
stage: 'multicall-sent',
|
|
164
|
-
args: [],
|
|
165
|
-
method: '',
|
|
166
|
-
from: from,
|
|
167
|
-
contractAddress: this.address,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
// Wait for the transaction to be mined
|
|
171
|
-
this.logger.debug(`Waiting for transaction to be mined... ${userOpHash}`);
|
|
172
|
-
const txReceipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });
|
|
173
|
-
this.logger.debug(`Transaction mined: ${userOpHash}`);
|
|
174
|
-
return txReceipt.receipt;
|
|
175
|
-
}
|
|
176
|
-
catch (err) {
|
|
177
|
-
if (err instanceof BaseError) {
|
|
178
|
-
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
179
|
-
this.logger.error(`revertError: ${String(revertError)}`);
|
|
180
|
-
}
|
|
181
|
-
throw new ContractsError(`Multicall failed: ${err}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
async internalSendSmartAccount(name, from, args, txparams, progress) {
|
|
185
|
-
const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args);
|
|
186
|
-
const { gasLimit, value } = txparams;
|
|
187
|
-
if (progress) {
|
|
188
|
-
progress({
|
|
189
|
-
stage: 'sending',
|
|
190
|
-
args: functionInputs,
|
|
191
|
-
method: name,
|
|
192
|
-
from: from,
|
|
193
|
-
value,
|
|
194
|
-
contractName: this.contractName,
|
|
195
|
-
contractAddress: this.address,
|
|
196
|
-
gasLimit,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
const ZERODEV_RPC = `https://rpc.zerodev.app/api/v3/${this.config.zeroDevProjectId}/chain/${this.config.chainId}`;
|
|
200
|
-
try {
|
|
201
|
-
await this.client.public.simulateContract({
|
|
202
|
-
address: this.address,
|
|
203
|
-
abi: this.contract.abi,
|
|
204
|
-
functionName: name,
|
|
205
|
-
args,
|
|
206
|
-
account: from,
|
|
207
|
-
...(txparams.value && { value: txparams.value }),
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
if (err instanceof BaseError) {
|
|
212
|
-
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
213
|
-
this.logger.error(`revertError: ${String(revertError)}`);
|
|
214
|
-
}
|
|
215
|
-
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
216
|
-
}
|
|
217
|
-
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
218
|
-
chain: getChain(this.config.chainId),
|
|
219
|
-
transport: http(ZERODEV_RPC),
|
|
220
|
-
});
|
|
221
|
-
const kernelClient = createKernelAccountClient({
|
|
222
|
-
account: from,
|
|
223
|
-
// Replace with your chain
|
|
224
|
-
chain: getChain(this.config.chainId),
|
|
225
|
-
// Find the RPC in your ZeroDev dashboard
|
|
226
|
-
bundlerTransport: http(ZERODEV_RPC),
|
|
227
|
-
// Required - the public client
|
|
228
|
-
client: this.contract.publicClient,
|
|
229
|
-
// Optional -- only if you want to use a paymaster
|
|
230
|
-
paymaster: {
|
|
231
|
-
getPaymasterData: (userOperation) => {
|
|
232
|
-
return zerodevPaymaster.sponsorUserOperation({
|
|
233
|
-
userOperation,
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
const data = encodeFunctionData({ abi: this.contract.abi, functionName: name, args });
|
|
239
|
-
let userOpHash;
|
|
240
|
-
try {
|
|
241
|
-
userOpHash = await kernelClient.sendUserOperation({
|
|
242
|
-
callData: await kernelClient.account.encodeCalls([
|
|
243
|
-
{
|
|
244
|
-
to: this.address,
|
|
245
|
-
value: txparams.value || 0n,
|
|
246
|
-
data,
|
|
247
|
-
},
|
|
248
|
-
]),
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
catch (err) {
|
|
252
|
-
if (err instanceof BaseError) {
|
|
253
|
-
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
254
|
-
this.logger.error(`revertError: ${String(revertError)}`);
|
|
255
|
-
}
|
|
256
|
-
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
257
|
-
}
|
|
258
|
-
if (progress) {
|
|
259
|
-
progress({
|
|
260
|
-
stage: 'sent',
|
|
261
|
-
args: functionInputs,
|
|
262
|
-
userOpHash,
|
|
263
|
-
method: name,
|
|
264
|
-
from: from,
|
|
265
|
-
value,
|
|
266
|
-
contractName: this.contractName,
|
|
267
|
-
contractAddress: this.address,
|
|
268
|
-
gasLimit,
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
const txReceipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });
|
|
272
|
-
if (progress) {
|
|
273
|
-
progress({
|
|
274
|
-
stage: 'receipt',
|
|
275
|
-
args: functionInputs,
|
|
276
|
-
txReceipt,
|
|
277
|
-
method: name,
|
|
278
|
-
from: from,
|
|
279
|
-
value,
|
|
280
|
-
contractName: this.contractName,
|
|
281
|
-
contractAddress: this.address,
|
|
282
|
-
gasLimit,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
return txReceipt;
|
|
286
|
-
}
|
|
287
|
-
async internalSimulateSmartAccount(name, from, args, txparams) {
|
|
288
|
-
try {
|
|
289
|
-
await this.client.public.simulateContract({
|
|
290
|
-
address: this.address,
|
|
291
|
-
abi: this.contract.abi,
|
|
292
|
-
functionName: name,
|
|
293
|
-
args,
|
|
294
|
-
account: from.address,
|
|
295
|
-
...(txparams.value && { value: txparams.value }),
|
|
296
|
-
});
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
catch (err) {
|
|
300
|
-
throw new ContractSimulationError(`Error Simulating contract call "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
async localAccountSimulate(name, from, args, txparams) {
|
|
304
|
-
try {
|
|
305
|
-
await this.client.public.simulateContract({
|
|
306
|
-
address: this.address,
|
|
307
|
-
abi: this.contract.abi,
|
|
308
|
-
functionName: name,
|
|
309
|
-
args,
|
|
310
|
-
account: from,
|
|
311
|
-
...(txparams.value && { value: txparams.value }),
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
catch (err) {
|
|
315
|
-
throw new ContractSimulationError(`Error Simulating contract call "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
316
|
-
}
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
async localAccountSend(name, from, args, txparams, progress) {
|
|
320
|
-
const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args);
|
|
321
|
-
// Uncomment to debug contract calls
|
|
322
|
-
// if (name === 'order') {
|
|
323
|
-
// const functionSignature = getSignatureOfFunction(this.contract.abi, name, args)
|
|
324
|
-
// this.logger.info(`Making contract call ....: ${name} - ${from}`)
|
|
325
|
-
// this.logger.info(`With args: `, JSON.stringify(args, jsonReplacer))
|
|
326
|
-
// this.logger.info(`And signature: ${JSON.stringify(functionSignature, jsonReplacer)}`)
|
|
327
|
-
// this.logger.info('And amount: ', txparams.value)
|
|
328
|
-
// }
|
|
329
|
-
// abi.filter(({name, inputs}) => name === 'closeSignals' && inputs.length === 1)
|
|
330
|
-
// const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.inputs.length === args.length)
|
|
331
|
-
// const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.type === 'function')
|
|
332
|
-
// console.debug('abi', this.contract.abi.filter((abi) => abi.name === name))
|
|
333
|
-
// console.debug('abiFilter', abiFilter)
|
|
334
|
-
// if (!abiFilter)
|
|
335
|
-
// throw new ContractsError(
|
|
336
|
-
// `No ABI found for method "${name}" with ${args.length} arguments on contract "${this.contractName}"`,
|
|
337
|
-
// )
|
|
338
|
-
const { gasLimit, value } = txparams;
|
|
339
|
-
// make the call
|
|
340
|
-
if (progress) {
|
|
341
|
-
progress({
|
|
342
|
-
stage: 'sending',
|
|
343
|
-
args: functionInputs,
|
|
344
|
-
method: name,
|
|
345
|
-
from,
|
|
346
|
-
value,
|
|
347
|
-
contractName: this.contractName,
|
|
348
|
-
contractAddress: this.address,
|
|
349
|
-
gasLimit,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
let txHash;
|
|
353
|
-
try {
|
|
354
|
-
const { request } = await this.client.public.simulateContract({
|
|
355
|
-
address: this.address,
|
|
356
|
-
abi: this.contract.abi,
|
|
357
|
-
functionName: name,
|
|
358
|
-
args,
|
|
359
|
-
account: from,
|
|
360
|
-
...(txparams.value && { value: txparams.value }),
|
|
361
|
-
});
|
|
362
|
-
txHash = await this.client.wallet.writeContract({
|
|
363
|
-
...request,
|
|
364
|
-
account: from,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
catch (err) {
|
|
368
|
-
if (err instanceof BaseError) {
|
|
369
|
-
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
370
|
-
this.logger.error(`revertError: ${String(revertError)}`);
|
|
371
|
-
}
|
|
372
|
-
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
373
|
-
}
|
|
374
|
-
if (progress) {
|
|
375
|
-
progress({
|
|
376
|
-
stage: 'sent',
|
|
377
|
-
args: functionInputs,
|
|
378
|
-
txHash,
|
|
379
|
-
method: name,
|
|
380
|
-
from,
|
|
381
|
-
value,
|
|
382
|
-
contractName: this.contractName,
|
|
383
|
-
contractAddress: this.address,
|
|
384
|
-
gasLimit,
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
const txReceipt = getTransactionReceipt({ txHash, publicClient: this.client.public });
|
|
388
|
-
if (progress) {
|
|
389
|
-
progress({
|
|
390
|
-
stage: 'receipt',
|
|
391
|
-
args: functionInputs,
|
|
392
|
-
txReceipt,
|
|
393
|
-
method: name,
|
|
394
|
-
from,
|
|
395
|
-
value,
|
|
396
|
-
contractName: this.contractName,
|
|
397
|
-
contractAddress: this.address,
|
|
398
|
-
gasLimit,
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
return txReceipt;
|
|
402
|
-
}
|
|
403
|
-
async localAccountMulticall(calls, from, txparams, progress) {
|
|
404
|
-
const receipts = [];
|
|
405
|
-
for (const call of calls) {
|
|
406
|
-
receipts.push(await this.localAccountSend(call.functionName, from, call.args, txparams, progress));
|
|
407
|
-
}
|
|
408
|
-
if (receipts.length > 0)
|
|
409
|
-
return receipts.pop();
|
|
410
|
-
else
|
|
411
|
-
throw new ContractsError(`No receipts found for multicall`);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract.js';
|
|
2
|
-
import { AccessManager } from './AccessManager.js';
|
|
3
|
-
import { AssetRegistry } from './AssetRegistry.js';
|
|
4
|
-
import { FiatPaymentTemplate } from './FiatPaymentTemplate.js';
|
|
5
|
-
import { FixedPaymentTemplate } from './FixedPaymentTemplate.js';
|
|
6
|
-
import { PayAsYouGoTemplate } from './PayAsYouGoTemplate.js';
|
|
7
|
-
import { NFT1155Credits } from './NFT1155Credits.js';
|
|
8
|
-
import { NFT1155ExpirableCredits } from './NFT1155ExpirableCredits.js';
|
|
9
|
-
import { NeverminedConfig } from './NVMConfig.js';
|
|
10
|
-
import { ProtocolStandardFees } from './ProtocolStandardFees.js';
|
|
11
|
-
export declare class ContractsApi extends Instantiable {
|
|
12
|
-
/**
|
|
13
|
-
* Return ContractsApi instance
|
|
14
|
-
* @param config
|
|
15
|
-
* @returns {@link ContractsApi}
|
|
16
|
-
*/
|
|
17
|
-
static getInstance(config: InstantiableConfig): Promise<ContractsApi>;
|
|
18
|
-
init(): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Access Manager smart contract instance.
|
|
21
|
-
*/
|
|
22
|
-
accessManager: AccessManager;
|
|
23
|
-
/**
|
|
24
|
-
* Nevermined Config smart contract instance.
|
|
25
|
-
*/
|
|
26
|
-
nvmConfig: NeverminedConfig;
|
|
27
|
-
/**
|
|
28
|
-
* Asset registry smart contract instance.
|
|
29
|
-
*/
|
|
30
|
-
assetRegistry: AssetRegistry;
|
|
31
|
-
/**
|
|
32
|
-
* NFT1155Credits smart contract instance.
|
|
33
|
-
* Manages non-expirable credits using the ERC-1155 standard.
|
|
34
|
-
* Allows minting, burning and balance checking of credits.
|
|
35
|
-
*/
|
|
36
|
-
nft1155Credits: NFT1155Credits;
|
|
37
|
-
/**
|
|
38
|
-
* NFT1155ExpirableCredits smart contract instance.
|
|
39
|
-
* Manages expirable credits using the ERC-1155 standard.
|
|
40
|
-
* Similar to NFT1155Credits but with an additional expiration mechanism.
|
|
41
|
-
* Credits minted through this contract will expire after a specified duration.
|
|
42
|
-
*/
|
|
43
|
-
nft1155ExpirableCredits: NFT1155ExpirableCredits;
|
|
44
|
-
/**
|
|
45
|
-
* FixedPaymentTemplate smart contract instance.
|
|
46
|
-
* Handles fixed payment agreements between parties.
|
|
47
|
-
* Used for creating and managing payment agreements with predefined terms.
|
|
48
|
-
*/
|
|
49
|
-
fixedPaymentTemplate: FixedPaymentTemplate;
|
|
50
|
-
/**
|
|
51
|
-
* PayAsYouGoTemplate smart contract instance.
|
|
52
|
-
* Handles pay-as-you-go payment agreements between parties.
|
|
53
|
-
* Used for creating and managing payment agreements with predefined terms.
|
|
54
|
-
*/
|
|
55
|
-
payAsYouGoTemplate: PayAsYouGoTemplate;
|
|
56
|
-
/**
|
|
57
|
-
* FiatPaymentTemplate smart contract instance.
|
|
58
|
-
* Handles fiat payment agreements between parties (i.e Stripe).
|
|
59
|
-
* Used for creating and managing payment agreements with predefined terms.
|
|
60
|
-
*/
|
|
61
|
-
fiatPaymentTemplate: FiatPaymentTemplate;
|
|
62
|
-
/**
|
|
63
|
-
* ProtocolStandardFees smart contract instance.
|
|
64
|
-
* It provides methods to calculate fees based on total amounts, price configurations, and credits configurations.
|
|
65
|
-
* This is the default fee controller for the protocol.
|
|
66
|
-
*/
|
|
67
|
-
protocolStandardFees: ProtocolStandardFees;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=ContractsApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsApi.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,qBAAa,YAAa,SAAQ,YAAY;IAC5C;;;;OAIG;WAC0B,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAM9E,IAAI;IAqCjB;;OAEG;IACI,aAAa,EAAG,aAAa,CAAA;IACpC;;OAEG;IACI,SAAS,EAAG,gBAAgB,CAAA;IAEnC;;OAEG;IACI,aAAa,EAAG,aAAa,CAAA;IAEpC;;;;OAIG;IACI,cAAc,EAAG,cAAc,CAAA;IAEtC;;;;;OAKG;IACI,uBAAuB,EAAG,uBAAuB,CAAA;IAExD;;;;OAIG;IACI,oBAAoB,EAAG,oBAAoB,CAAA;IAElD;;;;OAIG;IACI,kBAAkB,EAAG,kBAAkB,CAAA;IAE9C;;;;OAIG;IACI,mBAAmB,EAAG,mBAAmB,CAAA;IAEhD;;;;OAIG;IACI,oBAAoB,EAAG,oBAAoB,CAAA;CACnD"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Instantiable } from '../Instantiable.abstract.js';
|
|
2
|
-
export class ContractsApi extends Instantiable {
|
|
3
|
-
/**
|
|
4
|
-
* Return ContractsApi instance
|
|
5
|
-
* @param config
|
|
6
|
-
* @returns {@link ContractsApi}
|
|
7
|
-
*/
|
|
8
|
-
static async getInstance(config) {
|
|
9
|
-
const contractsApi = new ContractsApi();
|
|
10
|
-
contractsApi.setInstanceConfig(config);
|
|
11
|
-
return contractsApi;
|
|
12
|
-
}
|
|
13
|
-
async init() {
|
|
14
|
-
this.accessManager = await (await import('./AccessManager.js')).AccessManager.getInstance(this.instanceConfig);
|
|
15
|
-
this.nvmConfig = await (await import('./NVMConfig.js')).NeverminedConfig.getInstance(this.instanceConfig);
|
|
16
|
-
this.assetRegistry = await (await import('./AssetRegistry.js')).AssetRegistry.getInstance(this.instanceConfig);
|
|
17
|
-
this.nft1155Credits = await (await import('./NFT1155Credits.js')).NFT1155Credits.getInstance(this.instanceConfig);
|
|
18
|
-
this.nft1155ExpirableCredits = await (await import('./NFT1155ExpirableCredits.js')).NFT1155ExpirableCredits.getInstance(this.instanceConfig);
|
|
19
|
-
this.fixedPaymentTemplate = await (await import('./FixedPaymentTemplate.js')).FixedPaymentTemplate.getInstance(this.instanceConfig);
|
|
20
|
-
this.fiatPaymentTemplate = await (await import('./FiatPaymentTemplate.js')).FiatPaymentTemplate.getInstance(this.instanceConfig);
|
|
21
|
-
this.payAsYouGoTemplate = await (await import('./PayAsYouGoTemplate.js')).PayAsYouGoTemplate.getInstance(this.instanceConfig);
|
|
22
|
-
this.protocolStandardFees = await (await import('./ProtocolStandardFees.js')).ProtocolStandardFees.getInstance(this.instanceConfig);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Access Manager smart contract instance.
|
|
26
|
-
*/
|
|
27
|
-
accessManager;
|
|
28
|
-
/**
|
|
29
|
-
* Nevermined Config smart contract instance.
|
|
30
|
-
*/
|
|
31
|
-
nvmConfig;
|
|
32
|
-
/**
|
|
33
|
-
* Asset registry smart contract instance.
|
|
34
|
-
*/
|
|
35
|
-
assetRegistry;
|
|
36
|
-
/**
|
|
37
|
-
* NFT1155Credits smart contract instance.
|
|
38
|
-
* Manages non-expirable credits using the ERC-1155 standard.
|
|
39
|
-
* Allows minting, burning and balance checking of credits.
|
|
40
|
-
*/
|
|
41
|
-
nft1155Credits;
|
|
42
|
-
/**
|
|
43
|
-
* NFT1155ExpirableCredits smart contract instance.
|
|
44
|
-
* Manages expirable credits using the ERC-1155 standard.
|
|
45
|
-
* Similar to NFT1155Credits but with an additional expiration mechanism.
|
|
46
|
-
* Credits minted through this contract will expire after a specified duration.
|
|
47
|
-
*/
|
|
48
|
-
nft1155ExpirableCredits;
|
|
49
|
-
/**
|
|
50
|
-
* FixedPaymentTemplate smart contract instance.
|
|
51
|
-
* Handles fixed payment agreements between parties.
|
|
52
|
-
* Used for creating and managing payment agreements with predefined terms.
|
|
53
|
-
*/
|
|
54
|
-
fixedPaymentTemplate;
|
|
55
|
-
/**
|
|
56
|
-
* PayAsYouGoTemplate smart contract instance.
|
|
57
|
-
* Handles pay-as-you-go payment agreements between parties.
|
|
58
|
-
* Used for creating and managing payment agreements with predefined terms.
|
|
59
|
-
*/
|
|
60
|
-
payAsYouGoTemplate;
|
|
61
|
-
/**
|
|
62
|
-
* FiatPaymentTemplate smart contract instance.
|
|
63
|
-
* Handles fiat payment agreements between parties (i.e Stripe).
|
|
64
|
-
* Used for creating and managing payment agreements with predefined terms.
|
|
65
|
-
*/
|
|
66
|
-
fiatPaymentTemplate;
|
|
67
|
-
/**
|
|
68
|
-
* ProtocolStandardFees smart contract instance.
|
|
69
|
-
* It provides methods to calculate fees based on total amounts, price configurations, and credits configurations.
|
|
70
|
-
* This is the default fee controller for the protocol.
|
|
71
|
-
*/
|
|
72
|
-
protocolStandardFees;
|
|
73
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Account, Address } from 'viem';
|
|
2
|
-
import { SmartAccount } from 'viem/account-abstraction';
|
|
3
|
-
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
4
|
-
import { TxParameters } from '../models/Transactions.js';
|
|
5
|
-
import { ContractBase } from './ContractBase.js';
|
|
6
|
-
export declare class FiatPaymentTemplate extends ContractBase {
|
|
7
|
-
static getInstance(config: InstantiableConfig): Promise<FiatPaymentTemplate>;
|
|
8
|
-
order(planId: bigint, creditsReceiver: Address, owner: Account | SmartAccount, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=FiatPaymentTemplate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FiatPaymentTemplate.d.ts","sourceRoot":"","sources":["../../src/contracts/FiatPaymentTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,qBAAa,mBAAoB,SAAQ,YAAY;WACtB,WAAW,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC;IASlB,KAAK,CAChB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,iBAAiB,SAAK,EACtB,QAAQ,CAAC,EAAE,YAAY;CAU1B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { fiatPaymentTemplateConfig } from '../artifacts/generated.js';
|
|
2
|
-
import { generateZeroXId } from '../utils/helpers.js';
|
|
3
|
-
import { ContractBase } from './ContractBase.js';
|
|
4
|
-
export class FiatPaymentTemplate extends ContractBase {
|
|
5
|
-
static async getInstance(config) {
|
|
6
|
-
const fiatPaymentTemplate = new FiatPaymentTemplate('FiatPaymentTemplate', fiatPaymentTemplateConfig.address);
|
|
7
|
-
await fiatPaymentTemplate.init(config, fiatPaymentTemplateConfig);
|
|
8
|
-
return fiatPaymentTemplate;
|
|
9
|
-
}
|
|
10
|
-
async order(planId, creditsReceiver, owner, numberOfPurchases = 1n, txParams) {
|
|
11
|
-
const agreementIdSeed = generateZeroXId();
|
|
12
|
-
return this.send('order', owner, [agreementIdSeed, planId, creditsReceiver, numberOfPurchases, []], txParams);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Account, Address } from 'viem';
|
|
2
|
-
import { SmartAccount } from 'viem/account-abstraction';
|
|
3
|
-
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
4
|
-
import { ContractBase } from './ContractBase.js';
|
|
5
|
-
import { TxParameters } from '../models/Transactions.js';
|
|
6
|
-
export declare class FiatSettlementCondition extends ContractBase {
|
|
7
|
-
static getInstance(config: InstantiableConfig): Promise<FiatSettlementCondition>;
|
|
8
|
-
getFiatSettlementRole(): Promise<bigint>;
|
|
9
|
-
order(planId: bigint, planReceiver: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=FiatSettlementCondition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FiatSettlementCondition.d.ts","sourceRoot":"","sources":["../../src/contracts/FiatSettlementCondition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,qBAAa,uBAAwB,SAAQ,YAAY;WAC1B,WAAW,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,uBAAuB,CAAC;IAStB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxC,KAAK,CAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,QAAQ,CAAC,EAAE,YAAY;CAK1B"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { fiatSettlementConditionConfig } from '../artifacts/generated.js';
|
|
2
|
-
import { ContractBase } from './ContractBase.js';
|
|
3
|
-
import { generateZeroXId } from '../utils/helpers.js';
|
|
4
|
-
import { FIAT_SETTLEMENT_ROLE } from './Roles.js';
|
|
5
|
-
export class FiatSettlementCondition extends ContractBase {
|
|
6
|
-
static async getInstance(config) {
|
|
7
|
-
const fiatSettlementCondition = new FiatSettlementCondition('FiatSettlementCondition', fiatSettlementConditionConfig.address);
|
|
8
|
-
await fiatSettlementCondition.init(config, fiatSettlementConditionConfig);
|
|
9
|
-
return fiatSettlementCondition;
|
|
10
|
-
}
|
|
11
|
-
async getFiatSettlementRole() {
|
|
12
|
-
return FIAT_SETTLEMENT_ROLE;
|
|
13
|
-
}
|
|
14
|
-
async order(planId, planReceiver, owner, txParams) {
|
|
15
|
-
const agreementIdSeed = generateZeroXId();
|
|
16
|
-
return this.send('order', owner, [agreementIdSeed, planId, planReceiver, []], txParams);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Account, Address } from 'viem';
|
|
2
|
-
import { SmartAccount } from 'viem/account-abstraction';
|
|
3
|
-
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
4
|
-
import { TxParameters } from '../models/Transactions.js';
|
|
5
|
-
import { ContractBase } from './ContractBase.js';
|
|
6
|
-
export declare class FixedPaymentTemplate extends ContractBase {
|
|
7
|
-
private TOKEN_APPROVE_ABI;
|
|
8
|
-
static getInstance(config: InstantiableConfig): Promise<FixedPaymentTemplate>;
|
|
9
|
-
order(planId: bigint, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
10
|
-
simulateOrder(planId: bigint, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<boolean>;
|
|
11
|
-
approveERC20(totalAmount: bigint, tokenAddress: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | undefined>;
|
|
12
|
-
orderWithApprovals(planId: bigint, totalAmount: bigint, tokenAddress: Address, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | undefined>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=FixedPaymentTemplate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FixedPaymentTemplate.d.ts","sourceRoot":"","sources":["../../src/contracts/FixedPaymentTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,OAAO,EAAY,MAAM,MAAM,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAMvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAA;AAEhE,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,OAAO,CAAC,iBAAiB,CAEhB;WAEoB,WAAW,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,oBAAoB,CAAC;IASnB,KAAK,CAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,eAAe,CAAC,EAAE,OAAO,EACzB,iBAAiB,SAAK,EACtB,QAAQ,CAAC,EAAE,YAAY;IAWZ,aAAa,CACxB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,eAAe,CAAC,EAAE,OAAO,EACzB,iBAAiB,SAAK,EACtB,QAAQ,CAAC,EAAE,YAAY;IAWZ,YAAY,CACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,EACrB,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,QAAQ,CAAC,EAAE,YAAY;IAmBZ,kBAAkB,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,EACrB,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,eAAe,CAAC,EAAE,OAAO,EACzB,iBAAiB,SAAK,EACtB,QAAQ,CAAC,EAAE,YAAY;CA0B1B"}
|