@xelis/sdk 0.11.27 → 0.11.29
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.
|
@@ -125,20 +125,33 @@ class WSRPC {
|
|
|
125
125
|
}
|
|
126
126
|
dataCall(method, params, idRefObj) {
|
|
127
127
|
return new Promise(async (resolve, reject) => {
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
idRefObj
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
const sendDataCall = async () => {
|
|
129
|
+
const id = this.methodIdIncrement++;
|
|
130
|
+
if (idRefObj)
|
|
131
|
+
idRefObj.id = id;
|
|
132
|
+
const request = { id, jsonrpc: `2.0`, method };
|
|
133
|
+
if (params)
|
|
134
|
+
request.params = params;
|
|
135
|
+
const data = JSON.stringify(request);
|
|
136
|
+
const [err, res] = await (0, await_to_js_1.default)(this.rawCall(id, data));
|
|
137
|
+
if (err)
|
|
138
|
+
return reject(err);
|
|
139
|
+
if (res.error) {
|
|
140
|
+
return reject(res.error.message);
|
|
141
|
+
}
|
|
142
|
+
return resolve(res.result);
|
|
143
|
+
};
|
|
144
|
+
// make sure connection is open or wait
|
|
145
|
+
if (this.socket.readyState === isomorphic_ws_1.default.OPEN) {
|
|
146
|
+
sendDataCall();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const wait_for_open = () => {
|
|
150
|
+
sendDataCall();
|
|
151
|
+
this.socket.removeEventListener(`open`, wait_for_open);
|
|
152
|
+
};
|
|
153
|
+
this.socket.addEventListener(`open`, wait_for_open);
|
|
140
154
|
}
|
|
141
|
-
return resolve(res.result);
|
|
142
155
|
});
|
|
143
156
|
}
|
|
144
157
|
batchCall(requests) {
|
|
@@ -119,20 +119,33 @@ export class WSRPC {
|
|
|
119
119
|
}
|
|
120
120
|
dataCall(method, params, idRefObj) {
|
|
121
121
|
return new Promise(async (resolve, reject) => {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
idRefObj
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
const sendDataCall = async () => {
|
|
123
|
+
const id = this.methodIdIncrement++;
|
|
124
|
+
if (idRefObj)
|
|
125
|
+
idRefObj.id = id;
|
|
126
|
+
const request = { id, jsonrpc: `2.0`, method };
|
|
127
|
+
if (params)
|
|
128
|
+
request.params = params;
|
|
129
|
+
const data = JSON.stringify(request);
|
|
130
|
+
const [err, res] = await to(this.rawCall(id, data));
|
|
131
|
+
if (err)
|
|
132
|
+
return reject(err);
|
|
133
|
+
if (res.error) {
|
|
134
|
+
return reject(res.error.message);
|
|
135
|
+
}
|
|
136
|
+
return resolve(res.result);
|
|
137
|
+
};
|
|
138
|
+
// make sure connection is open or wait
|
|
139
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
140
|
+
sendDataCall();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const wait_for_open = () => {
|
|
144
|
+
sendDataCall();
|
|
145
|
+
this.socket.removeEventListener(`open`, wait_for_open);
|
|
146
|
+
};
|
|
147
|
+
this.socket.addEventListener(`open`, wait_for_open);
|
|
134
148
|
}
|
|
135
|
-
return resolve(res.result);
|
|
136
149
|
});
|
|
137
150
|
}
|
|
138
151
|
batchCall(requests) {
|
|
@@ -191,6 +191,11 @@ export interface ContractCall {
|
|
|
191
191
|
exclude: number[];
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
+
export type InterContractPermission = "none" | "all" | {
|
|
195
|
+
specific: ContractCall[];
|
|
196
|
+
} | {
|
|
197
|
+
exclude: ContractCall[];
|
|
198
|
+
};
|
|
194
199
|
export interface InvokeContractPayload {
|
|
195
200
|
contract: string;
|
|
196
201
|
deposits: {
|
|
@@ -199,11 +204,7 @@ export interface InvokeContractPayload {
|
|
|
199
204
|
entry_id: number;
|
|
200
205
|
max_gas: number;
|
|
201
206
|
parameters: number[][];
|
|
202
|
-
permission:
|
|
203
|
-
specific: ContractCall[];
|
|
204
|
-
} | {
|
|
205
|
-
exclude: ContractCall[];
|
|
206
|
-
};
|
|
207
|
+
permission: InterContractPermission;
|
|
207
208
|
}
|
|
208
209
|
export interface InvokeConstructorPayload {
|
|
209
210
|
max_gas: number;
|
|
@@ -550,7 +551,11 @@ export interface Module {
|
|
|
550
551
|
}
|
|
551
552
|
export interface GetContractModuleResult {
|
|
552
553
|
previous_topoheight: number | null;
|
|
553
|
-
|
|
554
|
+
topoheight: number;
|
|
555
|
+
data: {
|
|
556
|
+
module: Module | null;
|
|
557
|
+
version: string;
|
|
558
|
+
};
|
|
554
559
|
}
|
|
555
560
|
export interface GetContractDataResult {
|
|
556
561
|
previous_topoheight: number | null;
|
package/package.json
CHANGED