@nevermined-io/core-kit 0.0.58-rc0 → 0.0.58
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/artifacts/generated.d.ts +9775 -3866
- package/dist/artifacts/generated.d.ts.map +1 -1
- package/dist/artifacts/generated.js +7428 -3943
- package/dist/contracts/AssetRegistry.d.ts +47 -15
- package/dist/contracts/AssetRegistry.d.ts.map +1 -1
- package/dist/contracts/AssetRegistry.js +65 -26
- package/dist/contracts/ContractBase.d.ts +3 -0
- package/dist/contracts/ContractBase.d.ts.map +1 -1
- package/dist/contracts/ContractBase.js +80 -7
- package/dist/contracts/ContractsApi.d.ts +7 -0
- package/dist/contracts/ContractsApi.d.ts.map +1 -1
- package/dist/contracts/ContractsApi.js +7 -0
- package/dist/contracts/FiatPaymentTemplate.d.ts +1 -1
- package/dist/contracts/FiatPaymentTemplate.d.ts.map +1 -1
- package/dist/contracts/FiatPaymentTemplate.js +2 -2
- package/dist/contracts/FiatSettlementCondition.d.ts +1 -1
- package/dist/contracts/FiatSettlementCondition.d.ts.map +1 -1
- package/dist/contracts/FiatSettlementCondition.js +2 -2
- package/dist/contracts/FixedPaymentTemplate.d.ts +2 -2
- package/dist/contracts/FixedPaymentTemplate.d.ts.map +1 -1
- package/dist/contracts/FixedPaymentTemplate.js +5 -5
- package/dist/contracts/NFT1155Base.d.ts +9 -0
- package/dist/contracts/NFT1155Base.d.ts.map +1 -1
- package/dist/contracts/NFT1155Base.js +3 -0
- package/dist/contracts/PayAsYouGoTemplate.d.ts +13 -0
- package/dist/contracts/PayAsYouGoTemplate.d.ts.map +1 -0
- package/dist/contracts/PayAsYouGoTemplate.js +59 -0
- package/dist/errors/NeverminedErrors.d.ts +4 -1
- package/dist/errors/NeverminedErrors.d.ts.map +1 -1
- package/dist/errors/NeverminedErrors.js +7 -2
- package/dist/models/AgentAccessToken.d.ts +1 -1
- package/dist/models/AgentAccessToken.d.ts.map +1 -1
- package/dist/models/AgentAccessToken.js +1 -1
- package/dist/nevermined/api/PaymentsApi.d.ts +6 -4
- package/dist/nevermined/api/PaymentsApi.d.ts.map +1 -1
- package/dist/nevermined/api/PaymentsApi.js +41 -16
- package/dist/nevermined/api/ServicesApi.d.ts +0 -5
- package/dist/nevermined/api/ServicesApi.d.ts.map +1 -1
- package/dist/nevermined/api/ServicesApi.js +0 -6
- package/dist/nevermined/index.d.ts +0 -1
- package/dist/nevermined/index.d.ts.map +1 -1
- package/dist/nevermined/index.js +0 -1
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +1 -8
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +1 -1
- package/dist/nevermined/utils/BlockchainViemUtils.js +1 -11
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +1 -1
- package/dist/nevermined/utils/ZeroDevPolicies.js +20 -16
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +0 -1
- package/dist/utils/ConversionTypeHelpers.d.ts +1 -4
- package/dist/utils/ConversionTypeHelpers.d.ts.map +1 -1
- package/dist/utils/ConversionTypeHelpers.js +7 -8
- package/package.json +1 -1
- package/dist/nevermined/DID.d.ts +0 -45
- package/dist/nevermined/DID.d.ts.map +0 -1
- package/dist/nevermined/DID.js +0 -90
- package/dist/services/MetadataService.d.ts +0 -53
- package/dist/services/MetadataService.d.ts.map +0 -1
- package/dist/services/MetadataService.js +0 -155
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { CreditsConfig,
|
|
2
|
-
import { Account, Address,
|
|
1
|
+
import { CreditsConfig, DIDAgent, Plan, PriceConfig } from '@nvm-monorepo/commons';
|
|
2
|
+
import { Account, Address, TransactionReceipt } from 'viem';
|
|
3
3
|
import { SmartAccount, UserOperationReceipt } from 'viem/account-abstraction';
|
|
4
4
|
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
5
5
|
import { TxParameters } from '../models/Transactions.js';
|
|
6
6
|
import { ContractBase } from './ContractBase.js';
|
|
7
7
|
export declare class AssetRegistry extends ContractBase {
|
|
8
8
|
static getInstance(config: InstantiableConfig): Promise<AssetRegistry>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
didSeed: string;
|
|
9
|
+
hashAgentId(seed: string, owner: Address): Promise<bigint>;
|
|
10
|
+
getAgent(agentId: string | bigint): Promise<DIDAgent>;
|
|
11
|
+
register({ seed, url, plans, owner, txParams, }: {
|
|
12
|
+
seed: string;
|
|
14
13
|
url: string;
|
|
15
14
|
plans: bigint[];
|
|
16
15
|
owner: Account | SmartAccount;
|
|
17
16
|
txParams?: TxParameters;
|
|
18
17
|
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
18
|
+
createPayAsYouGoPlan({ priceConfig, creditsConfig, owner, nonce, addFees, isTrialPlan, organizationCryptoFee, organizationCryptoWallet, txParams, }: {
|
|
19
|
+
priceConfig: PriceConfig;
|
|
20
|
+
creditsConfig: CreditsConfig;
|
|
21
|
+
owner: Account | SmartAccount;
|
|
22
|
+
nonce?: bigint;
|
|
23
|
+
addFees?: boolean;
|
|
24
|
+
isTrialPlan?: boolean;
|
|
25
|
+
organizationCryptoFee?: bigint;
|
|
26
|
+
organizationCryptoWallet?: string;
|
|
27
|
+
txParams?: TxParameters;
|
|
28
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
19
29
|
createPlan({ priceConfig, creditsConfig, owner, nonce, addFees, isTrialPlan, organizationCryptoFee, organizationCryptoWallet, txParams, }: {
|
|
20
30
|
priceConfig: PriceConfig;
|
|
21
31
|
creditsConfig: CreditsConfig;
|
|
@@ -27,8 +37,8 @@ export declare class AssetRegistry extends ContractBase {
|
|
|
27
37
|
organizationCryptoWallet?: string;
|
|
28
38
|
txParams?: TxParameters;
|
|
29
39
|
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
registerAgentAndPlan({ seed, url, priceConfig, creditsConfig, owner, addFees, organizationCryptoFee, organizationCryptoWallet, txParams, }: {
|
|
41
|
+
seed: string;
|
|
32
42
|
url: string;
|
|
33
43
|
priceConfig: PriceConfig;
|
|
34
44
|
creditsConfig: CreditsConfig;
|
|
@@ -44,19 +54,20 @@ export declare class AssetRegistry extends ContractBase {
|
|
|
44
54
|
plan?: Plan;
|
|
45
55
|
}): Promise<bigint>;
|
|
46
56
|
planExists(id: bigint): Promise<boolean>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
planConfigPreFilter(priceConfig: PriceConfig, creditsConfig: CreditsConfig,
|
|
57
|
+
addPlanToAgent(planId: bigint, agentId: string | bigint, owner: Account | SmartAccount, txParams?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
58
|
+
removePlanFromAgent(planId: bigint, agentId: string | bigint, owner: Account | SmartAccount, txParams?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
59
|
+
planConfigPreFilter(priceConfig: PriceConfig, creditsConfig: CreditsConfig, includeFees?: boolean, organizationCryptoFee?: bigint, organizationCryptoWallet?: string): Promise<{
|
|
50
60
|
priceConfig: {
|
|
51
|
-
|
|
61
|
+
isCrypto: boolean;
|
|
52
62
|
tokenAddress?: Address;
|
|
53
63
|
amounts: bigint[];
|
|
54
64
|
receivers: string[];
|
|
55
|
-
|
|
65
|
+
externalPriceAddress?: Address;
|
|
56
66
|
feeController?: Address;
|
|
67
|
+
templateAddress?: Address;
|
|
57
68
|
};
|
|
58
69
|
creditsConfig: {
|
|
59
|
-
|
|
70
|
+
isRedemptionAmountFixed: boolean;
|
|
60
71
|
redemptionType: import("@nvm-monorepo/commons").RedemptionType;
|
|
61
72
|
proofRequired: boolean;
|
|
62
73
|
durationSecs: bigint;
|
|
@@ -67,7 +78,28 @@ export declare class AssetRegistry extends ContractBase {
|
|
|
67
78
|
};
|
|
68
79
|
}>;
|
|
69
80
|
hashPlanId(_priceConfig: PriceConfig, _creditsConfig: CreditsConfig, owner: Address, addFees?: boolean, nonce?: bigint, organizationCryptoFee?: bigint, organizationCryptoWallet?: string): Promise<bigint>;
|
|
81
|
+
/**
|
|
82
|
+
* @notice Checks if Nevermined fees are included in the payment distribution
|
|
83
|
+
* @param _planId The ID of the plan to check
|
|
84
|
+
* @return bool True if Nevermined fees are properly included
|
|
85
|
+
*/
|
|
70
86
|
areNeverminedFeesIncluded(priceConfig: PriceConfig): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* @notice Getting a payment distribution, it includes the Nevermined fees if not already included
|
|
89
|
+
* This method subsctracts the fees from the original amounts and adds a new entry for the fee recipient
|
|
90
|
+
* @param priceConfig The price configuration of the plan
|
|
91
|
+
* @param creditsConfig The credits configuration of the plan
|
|
92
|
+
* @return amounts Updated array of payment amounts including fees
|
|
93
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
94
|
+
*/
|
|
95
|
+
includeFeesInPaymentsDistribution(priceConfig: PriceConfig, creditsConfig: CreditsConfig): Promise<[bigint[], string[]]>;
|
|
96
|
+
/**
|
|
97
|
+
* @notice Adds Nevermined fees to the payment distribution if not already included
|
|
98
|
+
* @param priceConfig The price configuration of the plan
|
|
99
|
+
* @param creditsConfig The credits configuration of the plan
|
|
100
|
+
* @return amounts Updated array of payment amounts including fees
|
|
101
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
102
|
+
*/
|
|
71
103
|
addFeesToPaymentsDistribution(priceConfig: PriceConfig, creditsConfig: CreditsConfig): Promise<[bigint[], string[]]>;
|
|
72
104
|
}
|
|
73
105
|
//# sourceMappingURL=AssetRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetRegistry.d.ts","sourceRoot":"","sources":["../../src/contracts/AssetRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"AssetRegistry.d.ts","sourceRoot":"","sources":["../../src/contracts/AssetRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EA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5C,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAQhC;;;;;;OAMG;IACU,6BAA6B,CACxC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAOjC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { didZeroX } from '../utils/ConversionTypeHelpers.js';
|
|
1
|
+
import { isAddress, zeroAddress } from 'viem';
|
|
2
|
+
import { assetsRegistryConfig, nft1155CreditsAddress, nft1155ExpirableCreditsAddress, oneTimeCreatorHookAddress, payAsYouGoTemplateAddress, protocolStandardFeesAddress, } from '../artifacts/generated.js';
|
|
3
|
+
import { AgentNotFound, PlanNotFound } from '../errors/NeverminedErrors.js';
|
|
4
|
+
import { zeroX, toAgentId } from '../utils/ConversionTypeHelpers.js';
|
|
6
5
|
import { ContractBase } from './ContractBase.js';
|
|
7
6
|
export class AssetRegistry extends ContractBase {
|
|
8
7
|
static async getInstance(config) {
|
|
@@ -10,21 +9,32 @@ export class AssetRegistry extends ContractBase {
|
|
|
10
9
|
await assetRegistry.init(config, assetsRegistryConfig);
|
|
11
10
|
return assetRegistry;
|
|
12
11
|
}
|
|
13
|
-
async
|
|
14
|
-
return this.contract.read.
|
|
12
|
+
async hashAgentId(seed, owner) {
|
|
13
|
+
return this.contract.read.hashAgentId([seed, owner]);
|
|
15
14
|
}
|
|
16
|
-
async
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
15
|
+
async getAgent(agentId) {
|
|
16
|
+
const didAgent = await this.contract.read.getAgent([toAgentId(agentId)]);
|
|
17
|
+
if (didAgent.lastUpdated != 0)
|
|
18
|
+
return didAgent;
|
|
20
19
|
else
|
|
21
|
-
throw new
|
|
20
|
+
throw new AgentNotFound(`Agent with id ${agentId} not found`);
|
|
22
21
|
}
|
|
23
|
-
async
|
|
24
|
-
return this.
|
|
22
|
+
async register({ seed, url, plans, owner, txParams, }) {
|
|
23
|
+
return this.send('register', owner, [zeroX(seed), url, plans], txParams);
|
|
25
24
|
}
|
|
26
|
-
async
|
|
27
|
-
|
|
25
|
+
async createPayAsYouGoPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams, }) {
|
|
26
|
+
priceConfig.templateAddress = payAsYouGoTemplateAddress;
|
|
27
|
+
return this.createPlan({
|
|
28
|
+
priceConfig,
|
|
29
|
+
creditsConfig,
|
|
30
|
+
owner,
|
|
31
|
+
nonce,
|
|
32
|
+
addFees,
|
|
33
|
+
isTrialPlan,
|
|
34
|
+
organizationCryptoFee,
|
|
35
|
+
organizationCryptoWallet,
|
|
36
|
+
txParams,
|
|
37
|
+
});
|
|
28
38
|
}
|
|
29
39
|
async createPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams, }) {
|
|
30
40
|
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
@@ -36,9 +46,9 @@ export class AssetRegistry extends ContractBase {
|
|
|
36
46
|
return this.send('createPlan', owner, [_config.priceConfig, _config.creditsConfig, nonce], txParams);
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
|
-
async
|
|
49
|
+
async registerAgentAndPlan({ seed, url, priceConfig, creditsConfig, owner, addFees = true, organizationCryptoFee, organizationCryptoWallet, txParams, }) {
|
|
40
50
|
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
41
|
-
return this.send('
|
|
51
|
+
return this.send('registerAgentAndPlan', owner, [zeroX(seed), url, _config.priceConfig, _config.creditsConfig], txParams);
|
|
42
52
|
}
|
|
43
53
|
async getPlan(planId) {
|
|
44
54
|
const plan = this.contract.read.getPlan([planId]);
|
|
@@ -61,27 +71,29 @@ export class AssetRegistry extends ContractBase {
|
|
|
61
71
|
async planExists(id) {
|
|
62
72
|
return this.contract.read.planExists([id]);
|
|
63
73
|
}
|
|
64
|
-
async
|
|
65
|
-
return this.send('
|
|
74
|
+
async addPlanToAgent(planId, agentId, owner, txParams) {
|
|
75
|
+
return this.send('addPlanToAgent', owner, [toAgentId(agentId), planId], txParams);
|
|
66
76
|
}
|
|
67
|
-
async
|
|
68
|
-
return this.send('
|
|
77
|
+
async removePlanFromAgent(planId, agentId, owner, txParams) {
|
|
78
|
+
return this.send('removePlanFromAgent', owner, [toAgentId(agentId), planId], txParams);
|
|
69
79
|
}
|
|
70
|
-
async planConfigPreFilter(priceConfig, creditsConfig,
|
|
80
|
+
async planConfigPreFilter(priceConfig, creditsConfig, includeFees = true, organizationCryptoFee, organizationCryptoWallet) {
|
|
71
81
|
const _priceConfig = { ...priceConfig };
|
|
72
82
|
const _creditsConfig = { ...creditsConfig };
|
|
73
83
|
if (!priceConfig.feeController || !isAddress(priceConfig.feeController))
|
|
74
84
|
_priceConfig.feeController = protocolStandardFeesAddress;
|
|
85
|
+
if (!priceConfig.templateAddress || !isAddress(priceConfig.templateAddress))
|
|
86
|
+
_priceConfig.templateAddress = zeroAddress;
|
|
75
87
|
if (!creditsConfig.nftAddress || !isAddress(creditsConfig.nftAddress)) {
|
|
76
|
-
if (creditsConfig.
|
|
88
|
+
if (creditsConfig.durationSecs > 0n) {
|
|
77
89
|
_creditsConfig.nftAddress = nft1155ExpirableCreditsAddress;
|
|
78
90
|
}
|
|
79
91
|
else {
|
|
80
92
|
_creditsConfig.nftAddress = nft1155CreditsAddress;
|
|
81
93
|
}
|
|
82
94
|
}
|
|
83
|
-
if (
|
|
84
|
-
const fees = await this.
|
|
95
|
+
if (includeFees) {
|
|
96
|
+
const fees = await this.includeFeesInPaymentsDistribution(_priceConfig, _creditsConfig);
|
|
85
97
|
_priceConfig.amounts = fees[0];
|
|
86
98
|
_priceConfig.receivers = fees[1];
|
|
87
99
|
}
|
|
@@ -100,12 +112,39 @@ export class AssetRegistry extends ContractBase {
|
|
|
100
112
|
nonce,
|
|
101
113
|
]);
|
|
102
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* @notice Checks if Nevermined fees are included in the payment distribution
|
|
117
|
+
* @param _planId The ID of the plan to check
|
|
118
|
+
* @return bool True if Nevermined fees are properly included
|
|
119
|
+
*/
|
|
103
120
|
async areNeverminedFeesIncluded(priceConfig) {
|
|
104
121
|
return await this.contract.read.areNeverminedFeesIncluded([
|
|
105
122
|
priceConfig.amounts,
|
|
106
123
|
priceConfig.receivers,
|
|
107
124
|
]);
|
|
108
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* @notice Getting a payment distribution, it includes the Nevermined fees if not already included
|
|
128
|
+
* This method subsctracts the fees from the original amounts and adds a new entry for the fee recipient
|
|
129
|
+
* @param priceConfig The price configuration of the plan
|
|
130
|
+
* @param creditsConfig The credits configuration of the plan
|
|
131
|
+
* @return amounts Updated array of payment amounts including fees
|
|
132
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
133
|
+
*/
|
|
134
|
+
async includeFeesInPaymentsDistribution(priceConfig, creditsConfig) {
|
|
135
|
+
const result = await this.contract.read.includeFeesInPaymentsDistribution([
|
|
136
|
+
priceConfig,
|
|
137
|
+
creditsConfig,
|
|
138
|
+
]);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @notice Adds Nevermined fees to the payment distribution if not already included
|
|
143
|
+
* @param priceConfig The price configuration of the plan
|
|
144
|
+
* @param creditsConfig The credits configuration of the plan
|
|
145
|
+
* @return amounts Updated array of payment amounts including fees
|
|
146
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
147
|
+
*/
|
|
109
148
|
async addFeesToPaymentsDistribution(priceConfig, creditsConfig) {
|
|
110
149
|
const result = await this.contract.read.addFeesToPaymentsDistribution([
|
|
111
150
|
priceConfig,
|
|
@@ -21,9 +21,12 @@ export declare abstract class ContractBase extends Instantiable {
|
|
|
21
21
|
getTransactionReceipt(txHash: UserOperationReceipt | TransactionReceipt): Promise<TransactionReceipt>;
|
|
22
22
|
getTransactionLogs(txReceipt: TransactionReceipt | UserOperationReceipt, eventName?: string): any[];
|
|
23
23
|
multicall(calls: MulticallEntry[], from: Account | SmartAccount, params?: TxParameters): Promise<TransactionReceipt | undefined>;
|
|
24
|
+
simulate(functionName: string, from: Account | SmartAccount, args: any[], params?: TxParameters): Promise<boolean>;
|
|
24
25
|
send(functionName: string, from: Account | SmartAccount, args: any[], params?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
25
26
|
private internalMulticallSmartAccount;
|
|
26
27
|
private internalSendSmartAccount;
|
|
28
|
+
private internalSimulateSmartAccount;
|
|
29
|
+
private localAccountSimulate;
|
|
27
30
|
private localAccountSend;
|
|
28
31
|
private localAccountMulticall;
|
|
29
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractBase.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractBase.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,OAAO,EACP,OAAO,EAQP,kBAAkB,EACnB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,GAAG,CAAA;IACR,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,8BAAsB,YAAa,SAAQ,YAAY;IACrD,S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,EAAE,EACX,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,kBAAkB,GAAG,oBAAoB,CAAC;YAiBvC,6BAA6B;YA+E7B,wBAAwB;YA8HxB,4BAA4B;YAoD5B,oBAAoB;YAuBpB,gBAAgB;YAkGhB,qBAAqB;CAepC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk';
|
|
2
2
|
import { BaseError, ContractFunctionRevertedError, encodeFunctionData, getContract, http, parseAbi, parseEventLogs, } from 'viem';
|
|
3
|
-
import { ContractsError } from '../errors/index.js';
|
|
3
|
+
import { ContractsError, ContractSimulationError } from '../errors/index.js';
|
|
4
4
|
import { Instantiable } from '../Instantiable.abstract.js';
|
|
5
5
|
import { getInputsOfFunctionFormatted, getTransactionReceipt } from '../nevermined/index.js';
|
|
6
6
|
import { getChain } from '../utils/Network.js';
|
|
@@ -80,6 +80,23 @@ export class ContractBase extends Instantiable {
|
|
|
80
80
|
throw new ContractsError(`Account not supported`);
|
|
81
81
|
}
|
|
82
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
|
+
}
|
|
83
100
|
async send(functionName, from, args, params = {}) {
|
|
84
101
|
if (from.type === 'local') {
|
|
85
102
|
this.logger.debug(`Blockchain Send using Local account with functionName: ${functionName} and following args: ${args}`);
|
|
@@ -151,7 +168,7 @@ export class ContractBase extends Instantiable {
|
|
|
151
168
|
});
|
|
152
169
|
}
|
|
153
170
|
// Wait for the transaction to be mined
|
|
154
|
-
this.logger.debug(`Waiting for transaction to be mined
|
|
171
|
+
this.logger.debug(`Waiting for transaction to be mined... ${userOpHash}`);
|
|
155
172
|
const txReceipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });
|
|
156
173
|
this.logger.debug(`Transaction mined: ${userOpHash}`);
|
|
157
174
|
return txReceipt.receipt;
|
|
@@ -159,7 +176,7 @@ export class ContractBase extends Instantiable {
|
|
|
159
176
|
catch (err) {
|
|
160
177
|
if (err instanceof BaseError) {
|
|
161
178
|
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
162
|
-
this.logger.error(
|
|
179
|
+
this.logger.error(`revertError: ${String(revertError)}`);
|
|
163
180
|
}
|
|
164
181
|
throw new ContractsError(`Multicall failed: ${err}`);
|
|
165
182
|
}
|
|
@@ -193,7 +210,7 @@ export class ContractBase extends Instantiable {
|
|
|
193
210
|
catch (err) {
|
|
194
211
|
if (err instanceof BaseError) {
|
|
195
212
|
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
196
|
-
this.logger.error(
|
|
213
|
+
this.logger.error(`revertError: ${String(revertError)}`);
|
|
197
214
|
}
|
|
198
215
|
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
199
216
|
}
|
|
@@ -234,7 +251,7 @@ export class ContractBase extends Instantiable {
|
|
|
234
251
|
catch (err) {
|
|
235
252
|
if (err instanceof BaseError) {
|
|
236
253
|
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
237
|
-
this.logger.error(
|
|
254
|
+
this.logger.error(`revertError: ${String(revertError)}`);
|
|
238
255
|
}
|
|
239
256
|
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
240
257
|
}
|
|
@@ -267,10 +284,66 @@ export class ContractBase extends Instantiable {
|
|
|
267
284
|
}
|
|
268
285
|
return txReceipt;
|
|
269
286
|
}
|
|
287
|
+
async internalSimulateSmartAccount(name, from, args, txparams) {
|
|
288
|
+
const ZERODEV_RPC = `https://rpc.zerodev.app/api/v3/${this.config.zeroDevProjectId}/chain/${this.config.chainId}`;
|
|
289
|
+
try {
|
|
290
|
+
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
291
|
+
chain: getChain(this.config.chainId),
|
|
292
|
+
transport: http(ZERODEV_RPC),
|
|
293
|
+
});
|
|
294
|
+
const kernelClient = createKernelAccountClient({
|
|
295
|
+
account: from,
|
|
296
|
+
// Replace with your chain
|
|
297
|
+
chain: getChain(this.config.chainId),
|
|
298
|
+
// Find the RPC in your ZeroDev dashboard
|
|
299
|
+
bundlerTransport: http(ZERODEV_RPC),
|
|
300
|
+
// Required - the public client
|
|
301
|
+
client: this.contract.publicClient,
|
|
302
|
+
// Optional -- only if you want to use a paymaster
|
|
303
|
+
paymaster: {
|
|
304
|
+
getPaymasterData: (userOperation) => {
|
|
305
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
306
|
+
userOperation,
|
|
307
|
+
});
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
const data = encodeFunctionData({ abi: this.contract.abi, functionName: name, args });
|
|
312
|
+
kernelClient.estimateUserOperationGas({
|
|
313
|
+
callData: await kernelClient.account.encodeCalls([
|
|
314
|
+
{
|
|
315
|
+
to: this.address,
|
|
316
|
+
value: txparams.value || 0n,
|
|
317
|
+
data,
|
|
318
|
+
},
|
|
319
|
+
]),
|
|
320
|
+
});
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
catch (err) {
|
|
324
|
+
throw new ContractSimulationError(`Error Simulating contract call "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async localAccountSimulate(name, from, args, txparams) {
|
|
328
|
+
try {
|
|
329
|
+
await this.client.public.simulateContract({
|
|
330
|
+
address: this.address,
|
|
331
|
+
abi: this.contract.abi,
|
|
332
|
+
functionName: name,
|
|
333
|
+
args,
|
|
334
|
+
account: from,
|
|
335
|
+
...(txparams.value && { value: txparams.value }),
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
catch (err) {
|
|
339
|
+
throw new ContractSimulationError(`Error Simulating contract call "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
340
|
+
}
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
270
343
|
async localAccountSend(name, from, args, txparams, progress) {
|
|
271
344
|
const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args);
|
|
272
345
|
// Uncomment to debug contract calls
|
|
273
|
-
// if (name === '
|
|
346
|
+
// if (name === 'order') {
|
|
274
347
|
// const functionSignature = getSignatureOfFunction(this.contract.abi, name, args)
|
|
275
348
|
// this.logger.info(`Making contract call ....: ${name} - ${from}`)
|
|
276
349
|
// this.logger.info(`With args: `, JSON.stringify(args, jsonReplacer))
|
|
@@ -318,7 +391,7 @@ export class ContractBase extends Instantiable {
|
|
|
318
391
|
catch (err) {
|
|
319
392
|
if (err instanceof BaseError) {
|
|
320
393
|
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
321
|
-
this.logger.error(
|
|
394
|
+
this.logger.error(`revertError: ${String(revertError)}`);
|
|
322
395
|
}
|
|
323
396
|
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
324
397
|
}
|
|
@@ -3,6 +3,7 @@ import { AccessManager } from './AccessManager.js';
|
|
|
3
3
|
import { AssetRegistry } from './AssetRegistry.js';
|
|
4
4
|
import { FiatPaymentTemplate } from './FiatPaymentTemplate.js';
|
|
5
5
|
import { FixedPaymentTemplate } from './FixedPaymentTemplate.js';
|
|
6
|
+
import { PayAsYouGoTemplate } from './PayAsYouGoTemplate.js';
|
|
6
7
|
import { NFT1155Credits } from './NFT1155Credits.js';
|
|
7
8
|
import { NFT1155ExpirableCredits } from './NFT1155ExpirableCredits.js';
|
|
8
9
|
import { NeverminedConfig } from './NVMConfig.js';
|
|
@@ -46,6 +47,12 @@ export declare class ContractsApi extends Instantiable {
|
|
|
46
47
|
* Used for creating and managing payment agreements with predefined terms.
|
|
47
48
|
*/
|
|
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;
|
|
49
56
|
/**
|
|
50
57
|
* FiatPaymentTemplate smart contract instance.
|
|
51
58
|
* Handles fiat payment agreements between parties (i.e Stripe).
|
|
@@ -1 +1 @@
|
|
|
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,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,C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E9C;;;;OAIG;IACI,mBAAmB,EAAG,mBAAmB,CAAA;IAEhD;;;;OAIG;IACI,oBAAoB,EAAG,oBAAoB,CAAA;CACnD"}
|
|
@@ -18,6 +18,7 @@ export class ContractsApi extends Instantiable {
|
|
|
18
18
|
this.nft1155ExpirableCredits = await (await import('./NFT1155ExpirableCredits.js')).NFT1155ExpirableCredits.getInstance(this.instanceConfig);
|
|
19
19
|
this.fixedPaymentTemplate = await (await import('./FixedPaymentTemplate.js')).FixedPaymentTemplate.getInstance(this.instanceConfig);
|
|
20
20
|
this.fiatPaymentTemplate = await (await import('./FiatPaymentTemplate.js')).FiatPaymentTemplate.getInstance(this.instanceConfig);
|
|
21
|
+
this.payAsYouGoTemplate = await (await import('./PayAsYouGoTemplate.js')).PayAsYouGoTemplate.getInstance(this.instanceConfig);
|
|
21
22
|
this.protocolStandardFees = await (await import('./ProtocolStandardFees.js')).ProtocolStandardFees.getInstance(this.instanceConfig);
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
@@ -51,6 +52,12 @@ export class ContractsApi extends Instantiable {
|
|
|
51
52
|
* Used for creating and managing payment agreements with predefined terms.
|
|
52
53
|
*/
|
|
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;
|
|
54
61
|
/**
|
|
55
62
|
* FiatPaymentTemplate smart contract instance.
|
|
56
63
|
* Handles fiat payment agreements between parties (i.e Stripe).
|
|
@@ -5,6 +5,6 @@ import { TxParameters } from '../models/Transactions.js';
|
|
|
5
5
|
import { ContractBase } from './ContractBase.js';
|
|
6
6
|
export declare class FiatPaymentTemplate extends ContractBase {
|
|
7
7
|
static getInstance(config: InstantiableConfig): Promise<FiatPaymentTemplate>;
|
|
8
|
-
|
|
8
|
+
order(planId: bigint, creditsReceiver: Address, owner: Account | SmartAccount, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=FiatPaymentTemplate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -7,8 +7,8 @@ export class FiatPaymentTemplate extends ContractBase {
|
|
|
7
7
|
await fiatPaymentTemplate.init(config, fiatPaymentTemplateConfig);
|
|
8
8
|
return fiatPaymentTemplate;
|
|
9
9
|
}
|
|
10
|
-
async
|
|
10
|
+
async order(planId, creditsReceiver, owner, numberOfPurchases = 1n, txParams) {
|
|
11
11
|
const agreementIdSeed = generateZeroXId();
|
|
12
|
-
return this.send('
|
|
12
|
+
return this.send('order', owner, [agreementIdSeed, planId, creditsReceiver, numberOfPurchases, []], txParams);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -6,6 +6,6 @@ import { TxParameters } from '../models/Transactions.js';
|
|
|
6
6
|
export declare class FiatSettlementCondition extends ContractBase {
|
|
7
7
|
static getInstance(config: InstantiableConfig): Promise<FiatSettlementCondition>;
|
|
8
8
|
getFiatSettlementRole(): Promise<bigint>;
|
|
9
|
-
|
|
9
|
+
order(planId: bigint, planReceiver: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=FiatSettlementCondition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -11,8 +11,8 @@ export class FiatSettlementCondition extends ContractBase {
|
|
|
11
11
|
async getFiatSettlementRole() {
|
|
12
12
|
return FIAT_SETTLEMENT_ROLE;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
14
|
+
async order(planId, planReceiver, owner, txParams) {
|
|
15
15
|
const agreementIdSeed = generateZeroXId();
|
|
16
|
-
return this.send('
|
|
16
|
+
return this.send('order', owner, [agreementIdSeed, planId, planReceiver, []], txParams);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -6,8 +6,8 @@ import { ContractBase } from './ContractBase.js';
|
|
|
6
6
|
export declare class FixedPaymentTemplate extends ContractBase {
|
|
7
7
|
private TOKEN_APPROVE_ABI;
|
|
8
8
|
static getInstance(config: InstantiableConfig): Promise<FixedPaymentTemplate>;
|
|
9
|
-
|
|
9
|
+
order(planId: bigint, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
10
10
|
approveERC20(totalAmount: bigint, tokenAddress: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | undefined>;
|
|
11
|
-
|
|
11
|
+
orderWithApprovals(planId: bigint, totalAmount: bigint, tokenAddress: Address, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | undefined>;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=FixedPaymentTemplate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,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"}
|
|
@@ -11,9 +11,9 @@ export class FixedPaymentTemplate extends ContractBase {
|
|
|
11
11
|
await fixedPaymentTemplate.init(config, fixedPaymentTemplateConfig);
|
|
12
12
|
return fixedPaymentTemplate;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
14
|
+
async order(planId, owner, creditsReceiver, numberOfPurchases = 1n, txParams) {
|
|
15
15
|
const agreementIdSeed = generateZeroXId();
|
|
16
|
-
return this.send('
|
|
16
|
+
return this.send('order', owner, [agreementIdSeed, planId, creditsReceiver || owner.address, numberOfPurchases, []], txParams);
|
|
17
17
|
}
|
|
18
18
|
async approveERC20(totalAmount, tokenAddress, owner, txParams) {
|
|
19
19
|
const calls = [
|
|
@@ -32,7 +32,7 @@ export class FixedPaymentTemplate extends ContractBase {
|
|
|
32
32
|
];
|
|
33
33
|
return await this.multicall(calls, owner, txParams);
|
|
34
34
|
}
|
|
35
|
-
async
|
|
35
|
+
async orderWithApprovals(planId, totalAmount, tokenAddress, owner, creditsReceiver, numberOfPurchases = 1n, txParams) {
|
|
36
36
|
const agreementIdSeed = generateZeroXId();
|
|
37
37
|
const calls = [
|
|
38
38
|
{
|
|
@@ -50,8 +50,8 @@ export class FixedPaymentTemplate extends ContractBase {
|
|
|
50
50
|
{
|
|
51
51
|
contractAddress: this.address,
|
|
52
52
|
abi: this.contract.abi,
|
|
53
|
-
functionName: '
|
|
54
|
-
args: [agreementIdSeed, planId, creditsReceiver || owner.address, []],
|
|
53
|
+
functionName: 'order',
|
|
54
|
+
args: [agreementIdSeed, planId, creditsReceiver || owner.address, numberOfPurchases, []],
|
|
55
55
|
},
|
|
56
56
|
];
|
|
57
57
|
return await this.multicall(calls, owner, txParams);
|
|
@@ -21,6 +21,15 @@ export declare abstract class NFT1155Base extends ContractBase {
|
|
|
21
21
|
data?: string;
|
|
22
22
|
txParams?: TxParameters;
|
|
23
23
|
}): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
24
|
+
simulateCreditsRedemption({ from, planId, amount, keyspace, signature, owner, txParams, }: {
|
|
25
|
+
from: Address;
|
|
26
|
+
planId: bigint;
|
|
27
|
+
amount: bigint;
|
|
28
|
+
keyspace?: bigint;
|
|
29
|
+
signature?: string;
|
|
30
|
+
owner: Account | SmartAccount;
|
|
31
|
+
txParams?: TxParameters;
|
|
32
|
+
}): Promise<boolean>;
|
|
24
33
|
burn({ from, planId, amount, keyspace, signature, owner, txParams, }: {
|
|
25
34
|
from: Address;
|
|
26
35
|
planId: bigint;
|