@kynesyslabs/demosdk 2.3.28 → 2.4.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/build/abstraction/Identities.d.ts +10 -1
- package/build/abstraction/Identities.js +34 -4
- package/build/abstraction/Identities.js.map +1 -1
- package/build/contracts/ContractDeployer.d.ts +34 -0
- package/build/contracts/ContractDeployer.js +196 -0
- package/build/contracts/ContractDeployer.js.map +1 -0
- package/build/contracts/ContractFactory.d.ts +52 -0
- package/build/contracts/ContractFactory.js +98 -0
- package/build/contracts/ContractFactory.js.map +1 -0
- package/build/contracts/ContractInstance.d.ts +51 -0
- package/build/contracts/ContractInstance.js +138 -0
- package/build/contracts/ContractInstance.js.map +1 -0
- package/build/contracts/ContractInteractor.d.ts +55 -0
- package/build/contracts/ContractInteractor.js +242 -0
- package/build/contracts/ContractInteractor.js.map +1 -0
- package/build/contracts/index.d.ts +9 -0
- package/build/contracts/index.js +16 -0
- package/build/contracts/index.js.map +1 -0
- package/build/contracts/templates/TemplateRegistry.d.ts +71 -0
- package/build/contracts/templates/TemplateRegistry.js +404 -0
- package/build/contracts/templates/TemplateRegistry.js.map +1 -0
- package/build/contracts/templates/TemplateValidator.d.ts +55 -0
- package/build/contracts/templates/TemplateValidator.js +202 -0
- package/build/contracts/templates/TemplateValidator.js.map +1 -0
- package/build/contracts/types/ContractABI.d.ts +111 -0
- package/build/contracts/types/ContractABI.js +6 -0
- package/build/contracts/types/ContractABI.js.map +1 -0
- package/build/contracts/types/TypedContract.d.ts +34 -0
- package/build/contracts/types/TypedContract.js +6 -0
- package/build/contracts/types/TypedContract.js.map +1 -0
- package/build/types/abstraction/index.d.ts +7 -1
- package/build/types/web2/discord.d.ts +8 -0
- package/build/types/web2/discord.js +3 -0
- package/build/types/web2/discord.js.map +1 -0
- package/build/websdk/DemosContracts.d.ts +140 -0
- package/build/websdk/DemosContracts.js +185 -0
- package/build/websdk/DemosContracts.js.map +1 -0
- package/build/websdk/demosclass.d.ts +6 -0
- package/build/websdk/demosclass.js +5 -0
- package/build/websdk/demosclass.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract instance wrapper for easy interaction
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ContractInstance = void 0;
|
|
7
|
+
const ContractInteractor_1 = require("./ContractInteractor");
|
|
8
|
+
class ContractInstance {
|
|
9
|
+
constructor(demos, address, abi) {
|
|
10
|
+
this.demos = demos;
|
|
11
|
+
this.address = address;
|
|
12
|
+
this.abi = abi;
|
|
13
|
+
this.methods = {};
|
|
14
|
+
this.interactor = new ContractInteractor_1.ContractInteractor(demos);
|
|
15
|
+
// Set up method proxies if ABI is provided
|
|
16
|
+
if (abi && abi.functions) {
|
|
17
|
+
this.setupMethodProxies();
|
|
18
|
+
}
|
|
19
|
+
// Set up general proxy for dynamic method calls
|
|
20
|
+
return new Proxy(this, {
|
|
21
|
+
get: (target, prop) => {
|
|
22
|
+
// Return existing properties
|
|
23
|
+
if (prop in target) {
|
|
24
|
+
return target[prop];
|
|
25
|
+
}
|
|
26
|
+
// Create dynamic method caller
|
|
27
|
+
if (typeof prop === 'string' && !prop.startsWith('_')) {
|
|
28
|
+
return (...args) => this.call(prop, args);
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Call a contract method
|
|
36
|
+
*/
|
|
37
|
+
async call(method, args = [], options) {
|
|
38
|
+
return await this.interactor.call(this.address, method, args, options);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Send DEM with a contract call
|
|
42
|
+
*/
|
|
43
|
+
async callWithValue(method, args, value, options) {
|
|
44
|
+
return await this.call(method, args, {
|
|
45
|
+
...options,
|
|
46
|
+
value
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get contract state (if accessible)
|
|
51
|
+
*/
|
|
52
|
+
async getState(key) {
|
|
53
|
+
if (key) {
|
|
54
|
+
return await this.call('getState', [key]);
|
|
55
|
+
}
|
|
56
|
+
return await this.call('getState', []);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get contract metadata
|
|
60
|
+
*/
|
|
61
|
+
async getMetadata() {
|
|
62
|
+
const result = await this.demos.rpcCall({
|
|
63
|
+
method: 'getContractMetadata',
|
|
64
|
+
params: [this.address]
|
|
65
|
+
});
|
|
66
|
+
return result.result === 200 ? result.response : null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get contract events
|
|
70
|
+
*/
|
|
71
|
+
async getEvents(params) {
|
|
72
|
+
const result = await this.demos.rpcCall({
|
|
73
|
+
method: 'getContractEvents',
|
|
74
|
+
params: [{
|
|
75
|
+
contractAddress: this.address,
|
|
76
|
+
...params
|
|
77
|
+
}]
|
|
78
|
+
});
|
|
79
|
+
return result.result === 200 ? result.response.events : [];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Setup method proxies based on ABI
|
|
83
|
+
*/
|
|
84
|
+
setupMethodProxies() {
|
|
85
|
+
if (!this.abi || !this.abi.functions)
|
|
86
|
+
return;
|
|
87
|
+
for (const func of this.abi.functions) {
|
|
88
|
+
if (func.visibility === 'public') {
|
|
89
|
+
this.methods[func.name] = async (...args) => {
|
|
90
|
+
// Validate argument count
|
|
91
|
+
const requiredParams = func.parameters.filter(p => !p.optional).length;
|
|
92
|
+
if (args.length < requiredParams) {
|
|
93
|
+
throw new Error(`Method ${func.name} expects at least ${requiredParams} arguments, got ${args.length}`);
|
|
94
|
+
}
|
|
95
|
+
// Determine if this is a view call
|
|
96
|
+
const isView = func.mutability === 'view' || func.mutability === 'pure';
|
|
97
|
+
const options = {};
|
|
98
|
+
if (func.mutability === 'payable' && args.length > func.parameters.length) {
|
|
99
|
+
// Last argument might be value
|
|
100
|
+
options.value = args.pop();
|
|
101
|
+
}
|
|
102
|
+
const result = await this.call(func.name, args, options);
|
|
103
|
+
if (result.success) {
|
|
104
|
+
return result.result;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw new Error(result.error || `Call to ${func.name} failed`);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a typed instance from ABI
|
|
115
|
+
*/
|
|
116
|
+
static fromABI(demos, address, abi) {
|
|
117
|
+
return new ContractInstance(demos, address, abi);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Wait for contract to be deployed at address
|
|
121
|
+
*/
|
|
122
|
+
static async waitForDeployment(demos, address, timeout = 30000) {
|
|
123
|
+
const startTime = Date.now();
|
|
124
|
+
while (Date.now() - startTime < timeout) {
|
|
125
|
+
const result = await demos.rpcCall({
|
|
126
|
+
method: 'getContract',
|
|
127
|
+
params: [address]
|
|
128
|
+
});
|
|
129
|
+
if (result.result === 200 && result.response) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.ContractInstance = ContractInstance;
|
|
138
|
+
//# sourceMappingURL=ContractInstance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractInstance.js","sourceRoot":"","sources":["../../../src/contracts/ContractInstance.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,6DAAyD;AAQzD,MAAa,gBAAgB;IAIzB,YACY,KAAY,EACb,OAAe,EACf,GAAiB;QAFhB,UAAK,GAAL,KAAK,CAAO;QACb,YAAO,GAAP,OAAO,CAAQ;QACf,QAAG,GAAH,GAAG,CAAc;QALrB,YAAO,GAAM,EAAO,CAAA;QAOvB,IAAI,CAA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B,KAAY,EACZ,OAAe,EACf,UAAkB,KAAK;QAEvB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAE5B,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC;gBAC/B,MAAM,EAAE,aAAa;gBACrB,MAAM,EAAE,CAAC,OAAO,CAAC;aACb,CAAC,CAAA;YAET,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAA;YACf,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;QAC3D,CAAC;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AArLD,4CAqLC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract interaction functionality for Demos SDK
|
|
3
|
+
*/
|
|
4
|
+
import { Demos } from '../websdk/demosclass';
|
|
5
|
+
import { ContractCallResult, ContractCallOptions } from './types/ContractABI';
|
|
6
|
+
export declare class ContractInteractor {
|
|
7
|
+
private demos;
|
|
8
|
+
constructor(demos: Demos);
|
|
9
|
+
/**
|
|
10
|
+
* Call a smart contract method
|
|
11
|
+
* @param contractAddress The contract address
|
|
12
|
+
* @param method The method name to call
|
|
13
|
+
* @param args Arguments for the method
|
|
14
|
+
* @param options Call options
|
|
15
|
+
* @returns Call result
|
|
16
|
+
*/
|
|
17
|
+
call<T = any>(contractAddress: string, method: string, args?: any[], options?: ContractCallOptions): Promise<ContractCallResult<T>>;
|
|
18
|
+
/**
|
|
19
|
+
* Batch multiple contract calls
|
|
20
|
+
*/
|
|
21
|
+
batchCall(calls: Array<{
|
|
22
|
+
contractAddress: string;
|
|
23
|
+
method: string;
|
|
24
|
+
args: any[];
|
|
25
|
+
options?: ContractCallOptions;
|
|
26
|
+
}>): Promise<ContractCallResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Read-only contract call (no transaction)
|
|
29
|
+
*/
|
|
30
|
+
private viewCall;
|
|
31
|
+
/**
|
|
32
|
+
* State-changing contract call (sends transaction)
|
|
33
|
+
*/
|
|
34
|
+
private transactionCall;
|
|
35
|
+
/**
|
|
36
|
+
* Build contract call transaction
|
|
37
|
+
*/
|
|
38
|
+
private buildCallTransaction;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a call is view/pure (read-only)
|
|
41
|
+
*/
|
|
42
|
+
private isViewCall;
|
|
43
|
+
/**
|
|
44
|
+
* Wait for transaction confirmation
|
|
45
|
+
*/
|
|
46
|
+
private waitForTransaction;
|
|
47
|
+
/**
|
|
48
|
+
* Helper to send RPC requests
|
|
49
|
+
*/
|
|
50
|
+
private sendRPC;
|
|
51
|
+
/**
|
|
52
|
+
* Helper to sign transactions
|
|
53
|
+
*/
|
|
54
|
+
private signTransaction;
|
|
55
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract interaction functionality for Demos SDK
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ContractInteractor = void 0;
|
|
40
|
+
const unifiedCrypto_1 = require("../encryption/unifiedCrypto");
|
|
41
|
+
const skeletons = __importStar(require("../websdk/utils/skeletons"));
|
|
42
|
+
class ContractInteractor {
|
|
43
|
+
constructor(demos) {
|
|
44
|
+
this.demos = demos;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Call a smart contract method
|
|
48
|
+
* @param contractAddress The contract address
|
|
49
|
+
* @param method The method name to call
|
|
50
|
+
* @param args Arguments for the method
|
|
51
|
+
* @param options Call options
|
|
52
|
+
* @returns Call result
|
|
53
|
+
*/
|
|
54
|
+
async call(contractAddress, method, args = [], options = {}) {
|
|
55
|
+
try {
|
|
56
|
+
// For view/pure calls, use call RPC (no transaction needed)
|
|
57
|
+
if (this.isViewCall(method, options)) {
|
|
58
|
+
return await this.viewCall(contractAddress, method, args);
|
|
59
|
+
}
|
|
60
|
+
// For state-changing calls, send a transaction
|
|
61
|
+
return await this.transactionCall(contractAddress, method, args, options);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
error: error.message || 'Contract call failed'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Batch multiple contract calls
|
|
72
|
+
*/
|
|
73
|
+
async batchCall(calls) {
|
|
74
|
+
const results = [];
|
|
75
|
+
for (const call of calls) {
|
|
76
|
+
const result = await this.call(call.contractAddress, call.method, call.args, call.options);
|
|
77
|
+
results.push(result);
|
|
78
|
+
}
|
|
79
|
+
return results;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Read-only contract call (no transaction)
|
|
83
|
+
*/
|
|
84
|
+
async viewCall(contractAddress, method, args) {
|
|
85
|
+
const result = await this.sendRPC({
|
|
86
|
+
method: 'contractCall',
|
|
87
|
+
params: [{
|
|
88
|
+
contractAddress,
|
|
89
|
+
method,
|
|
90
|
+
args,
|
|
91
|
+
readOnly: true
|
|
92
|
+
}]
|
|
93
|
+
});
|
|
94
|
+
if (result.result !== 200) {
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
error: result.response?.error || 'View call failed'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
success: true,
|
|
102
|
+
result: result.response.returnValue,
|
|
103
|
+
gasUsed: result.response.gasUsed
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* State-changing contract call (sends transaction)
|
|
108
|
+
*/
|
|
109
|
+
async transactionCall(contractAddress, method, args, options) {
|
|
110
|
+
// Validate wallet connection
|
|
111
|
+
if (!this.demos.walletConnected) {
|
|
112
|
+
throw new Error('Wallet not connected. Please connect a wallet first.');
|
|
113
|
+
}
|
|
114
|
+
// Build the call transaction
|
|
115
|
+
const tx = await this.buildCallTransaction(contractAddress, method, args, options);
|
|
116
|
+
// Send the transaction
|
|
117
|
+
const result = await this.sendRPC({
|
|
118
|
+
method: 'sendTransaction',
|
|
119
|
+
params: [tx]
|
|
120
|
+
});
|
|
121
|
+
if (result.result !== 200) {
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
error: result.response?.error || 'Transaction failed'
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Wait for confirmation if requested
|
|
128
|
+
if (options.waitForConfirmation !== false) {
|
|
129
|
+
const confirmation = await this.waitForTransaction(result.response.transactionHash, options.confirmations || 1);
|
|
130
|
+
if (!confirmation.success) {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
error: confirmation.error
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
success: true,
|
|
138
|
+
result: confirmation.returnValue,
|
|
139
|
+
gasUsed: confirmation.gasUsed,
|
|
140
|
+
events: confirmation.events,
|
|
141
|
+
transactionHash: result.response.transactionHash,
|
|
142
|
+
blockHeight: confirmation.blockHeight
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
transactionHash: result.response.transactionHash
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Build contract call transaction
|
|
152
|
+
*/
|
|
153
|
+
async buildCallTransaction(contractAddress, method, args, options) {
|
|
154
|
+
const { publicKey } = await this.demos.crypto.getIdentity('ed25519');
|
|
155
|
+
const publicKeyHex = (0, unifiedCrypto_1.uint8ArrayToHex)(publicKey);
|
|
156
|
+
const nonce = options.nonce ?? await this.demos.getAddressNonce(publicKeyHex);
|
|
157
|
+
const payload = {
|
|
158
|
+
contractAddress,
|
|
159
|
+
method,
|
|
160
|
+
args
|
|
161
|
+
};
|
|
162
|
+
const tx = structuredClone(skeletons.transaction);
|
|
163
|
+
tx.content.type = 'contractCall';
|
|
164
|
+
tx.content.data = ['contractCall', payload];
|
|
165
|
+
tx.content.nonce = nonce;
|
|
166
|
+
tx.content.from = publicKeyHex;
|
|
167
|
+
tx.content.timestamp = Date.now();
|
|
168
|
+
tx.content.amount = Number(options.value || 0);
|
|
169
|
+
// Sign the transaction
|
|
170
|
+
return await this.signTransaction(tx);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Check if a call is view/pure (read-only)
|
|
174
|
+
*/
|
|
175
|
+
isViewCall(method, options) {
|
|
176
|
+
// Check if explicitly marked as view
|
|
177
|
+
if (options.value && options.value > 0) {
|
|
178
|
+
return false; // Calls with value are never view
|
|
179
|
+
}
|
|
180
|
+
// Common view method patterns
|
|
181
|
+
const viewPatterns = [
|
|
182
|
+
/^get/i,
|
|
183
|
+
/^is/i,
|
|
184
|
+
/^has/i,
|
|
185
|
+
/^check/i,
|
|
186
|
+
/^view/i,
|
|
187
|
+
/^read/i,
|
|
188
|
+
/balance/i,
|
|
189
|
+
/supply/i,
|
|
190
|
+
/owner/i,
|
|
191
|
+
/allowance/i
|
|
192
|
+
];
|
|
193
|
+
return viewPatterns.some(pattern => pattern.test(method));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Wait for transaction confirmation
|
|
197
|
+
*/
|
|
198
|
+
async waitForTransaction(txHash, confirmations) {
|
|
199
|
+
const maxAttempts = 30; // 30 seconds timeout
|
|
200
|
+
let attempts = 0;
|
|
201
|
+
while (attempts < maxAttempts) {
|
|
202
|
+
const result = await this.sendRPC({
|
|
203
|
+
method: 'getTransactionReceipt',
|
|
204
|
+
params: [txHash]
|
|
205
|
+
});
|
|
206
|
+
if (result.result === 200 && result.response) {
|
|
207
|
+
const receipt = result.response;
|
|
208
|
+
if (receipt.confirmations >= confirmations) {
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
returnValue: receipt.returnValue,
|
|
212
|
+
gasUsed: receipt.gasUsed,
|
|
213
|
+
events: receipt.events,
|
|
214
|
+
blockHeight: receipt.blockHeight
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
219
|
+
attempts++;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
success: false,
|
|
223
|
+
error: 'Transaction confirmation timeout'
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Helper to send RPC requests
|
|
228
|
+
*/
|
|
229
|
+
async sendRPC(request) {
|
|
230
|
+
// This will be implemented through the main Demos class
|
|
231
|
+
return await this.demos.rpcCall(request);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Helper to sign transactions
|
|
235
|
+
*/
|
|
236
|
+
async signTransaction(tx) {
|
|
237
|
+
// This will be implemented through the main Demos class
|
|
238
|
+
return await this.demos.sign(tx);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.ContractInteractor = ContractInteractor;
|
|
242
|
+
//# sourceMappingURL=ContractInteractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractInteractor.js","sourceRoot":"","sources":["../../../src/contracts/ContractInteractor.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASH,+DAA6D;AAC7D,qEAAsD;AAEtD,MAAa,kBAAkB;IAC3B,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CACN,eAAuB,EACvB,MAAc,EACd,OAAc,EAAE,EAChB,UAA+B,EAAE;QAEjC,IAAI,CAAC;YACD,4DAA4D;YAC5D,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;gBACnC,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;YAC7D,CAAC;YAED,+CAA+C;YAC/C,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe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AAA;QACd,CAAC;QAED,OAAO;YACH,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,kCAAkC;SAC5C,CAAA;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO,CAAC,OAAmB;QACrC,wDAAwD;QACxD,OAAO,MAAO,IAAI,CAAC,KAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACrD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,eAAe,CAAC,EAAO;QACjC,wDAAwD;QACxD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC;CACJ;AA5QD,gDA4QC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract module exports
|
|
3
|
+
*/
|
|
4
|
+
export { ContractDeployer } from './ContractDeployer';
|
|
5
|
+
export { ContractInteractor } from './ContractInteractor';
|
|
6
|
+
export { ContractInstance } from './ContractInstance';
|
|
7
|
+
export { ContractFactory, BatchBuilder } from './ContractFactory';
|
|
8
|
+
export type { ContractABI, ContractMetadata, ContractCallResult, ContractDeploymentResult, ContractCallOptions, ContractDeployOptions, ABIFunction, ABIEvent, ABIParameter } from './types/ContractABI';
|
|
9
|
+
export type { TypedContract, ContractInterface, ContractMethodParams, ContractMethodReturn } from './types/TypedContract';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract module exports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BatchBuilder = exports.ContractFactory = exports.ContractInstance = exports.ContractInteractor = exports.ContractDeployer = void 0;
|
|
7
|
+
var ContractDeployer_1 = require("./ContractDeployer");
|
|
8
|
+
Object.defineProperty(exports, "ContractDeployer", { enumerable: true, get: function () { return ContractDeployer_1.ContractDeployer; } });
|
|
9
|
+
var ContractInteractor_1 = require("./ContractInteractor");
|
|
10
|
+
Object.defineProperty(exports, "ContractInteractor", { enumerable: true, get: function () { return ContractInteractor_1.ContractInteractor; } });
|
|
11
|
+
var ContractInstance_1 = require("./ContractInstance");
|
|
12
|
+
Object.defineProperty(exports, "ContractInstance", { enumerable: true, get: function () { return ContractInstance_1.ContractInstance; } });
|
|
13
|
+
var ContractFactory_1 = require("./ContractFactory");
|
|
14
|
+
Object.defineProperty(exports, "ContractFactory", { enumerable: true, get: function () { return ContractFactory_1.ContractFactory; } });
|
|
15
|
+
Object.defineProperty(exports, "BatchBuilder", { enumerable: true, get: function () { return ContractFactory_1.BatchBuilder; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contracts/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA;AACzB,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAC3B,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA;AACzB,qDAAiE;AAAxD,kHAAA,eAAe,OAAA;AAAE,+GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Registry with Parameter Substitution
|
|
3
|
+
*
|
|
4
|
+
* Manages contract templates, validates parameters, and performs
|
|
5
|
+
* parameter substitution to generate deployable contract source code.
|
|
6
|
+
*/
|
|
7
|
+
import { TemplateSchema, ValidationResult } from './TemplateValidator';
|
|
8
|
+
export interface TemplateInfo {
|
|
9
|
+
name: string;
|
|
10
|
+
schema: TemplateSchema;
|
|
11
|
+
sourceFile: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SubstitutionResult {
|
|
15
|
+
success: boolean;
|
|
16
|
+
source?: string;
|
|
17
|
+
errors: string[];
|
|
18
|
+
warnings: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare class TemplateRegistry {
|
|
21
|
+
private static templates;
|
|
22
|
+
private static initialized;
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the template registry with built-in templates
|
|
25
|
+
*/
|
|
26
|
+
static initialize(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Register a new template
|
|
29
|
+
*/
|
|
30
|
+
static registerTemplate(templateInfo: TemplateInfo): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get all available template names
|
|
33
|
+
*/
|
|
34
|
+
static getAvailableTemplates(): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Get template information
|
|
37
|
+
*/
|
|
38
|
+
static getTemplate(name: string): TemplateInfo | null;
|
|
39
|
+
/**
|
|
40
|
+
* Get template schema for validation
|
|
41
|
+
*/
|
|
42
|
+
static getTemplateSchema(name: string): TemplateSchema | null;
|
|
43
|
+
/**
|
|
44
|
+
* Load template source code
|
|
45
|
+
*/
|
|
46
|
+
private static loadTemplateSource;
|
|
47
|
+
/**
|
|
48
|
+
* Get embedded template source (temporary implementation)
|
|
49
|
+
*/
|
|
50
|
+
private static getEmbeddedTemplateSource;
|
|
51
|
+
/**
|
|
52
|
+
* Validate template parameters
|
|
53
|
+
*/
|
|
54
|
+
static validateParameters(templateName: string, params: Record<string, any>): ValidationResult;
|
|
55
|
+
/**
|
|
56
|
+
* Generate contract source with parameter substitution
|
|
57
|
+
*/
|
|
58
|
+
static generateContract(templateName: string, params?: Record<string, any>): SubstitutionResult;
|
|
59
|
+
/**
|
|
60
|
+
* Perform parameter substitution in template source
|
|
61
|
+
*/
|
|
62
|
+
private static substituteParameters;
|
|
63
|
+
/**
|
|
64
|
+
* Format parameter value for code generation
|
|
65
|
+
*/
|
|
66
|
+
private static formatParameterValue;
|
|
67
|
+
/**
|
|
68
|
+
* Get template usage examples
|
|
69
|
+
*/
|
|
70
|
+
static getTemplateExample(templateName: string): string | null;
|
|
71
|
+
}
|