phantasma-sdk-ts 0.2.4 → 0.2.5
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/cjs/core/types/Carbon/Blockchain/TxMsgCall.js +57 -3
- package/dist/esm/core/types/Carbon/Blockchain/TxMsgCall.js +55 -2
- package/dist/types/core/types/Carbon/Blockchain/TxMsgCall.d.ts +12 -0
- package/dist/types/core/types/Carbon/Blockchain/TxMsgCall.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TxMsgCall = void 0;
|
|
3
|
+
exports.TxMsgCall = exports.MsgCallArgSections = void 0;
|
|
4
|
+
const CarbonSerialization_1 = require("../../CarbonSerialization");
|
|
5
|
+
class MsgCallArgSections {
|
|
6
|
+
constructor(argSections = []) {
|
|
7
|
+
this.argSections = argSections;
|
|
8
|
+
}
|
|
9
|
+
hasSections() {
|
|
10
|
+
return this.argSections.length > 0;
|
|
11
|
+
}
|
|
12
|
+
write(w) {
|
|
13
|
+
CarbonSerialization_1.Throw.Assert(this.argSections.length > 0, 'arg sections are empty');
|
|
14
|
+
w.write4(-this.argSections.length);
|
|
15
|
+
for (const section of this.argSections) {
|
|
16
|
+
if (section.registerOffset < 0) {
|
|
17
|
+
w.write4(section.registerOffset);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
w.write4(section.args.length);
|
|
21
|
+
if (section.args.length > 0) {
|
|
22
|
+
w.write(section.args);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static readWithCount(r, countNegative) {
|
|
27
|
+
CarbonSerialization_1.Throw.Assert(countNegative < 0, 'arg sections count must be negative');
|
|
28
|
+
const length = -countNegative;
|
|
29
|
+
const sections = new Array(length);
|
|
30
|
+
for (let i = 0; i < length; i++) {
|
|
31
|
+
const value = r.read4();
|
|
32
|
+
if (value < 0) {
|
|
33
|
+
sections[i] = { registerOffset: value, args: new Uint8Array() };
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const args = r.readExactly(value);
|
|
37
|
+
sections[i] = { registerOffset: 0, args };
|
|
38
|
+
}
|
|
39
|
+
return new MsgCallArgSections(sections);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.MsgCallArgSections = MsgCallArgSections;
|
|
4
43
|
class TxMsgCall {
|
|
5
44
|
constructor(moduleId = 0, methodId = 0, args = new Uint8Array()) {
|
|
6
45
|
this.moduleId = moduleId >>> 0;
|
|
7
46
|
this.methodId = methodId >>> 0;
|
|
8
47
|
this.args = args;
|
|
48
|
+
this.sections = null;
|
|
9
49
|
}
|
|
10
50
|
write(w) {
|
|
11
51
|
w.write4u(this.moduleId);
|
|
12
52
|
w.write4u(this.methodId);
|
|
13
|
-
|
|
53
|
+
if (this.sections && this.sections.hasSections()) {
|
|
54
|
+
this.sections.write(w);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
w.write4(this.args.length);
|
|
58
|
+
if (this.args.length > 0) {
|
|
59
|
+
w.write(this.args);
|
|
60
|
+
}
|
|
14
61
|
}
|
|
15
62
|
read(r) {
|
|
16
63
|
this.moduleId = r.read4u();
|
|
17
64
|
this.methodId = r.read4u();
|
|
18
|
-
|
|
65
|
+
const length = r.read4();
|
|
66
|
+
if (length >= 0) {
|
|
67
|
+
this.args = r.readExactly(length);
|
|
68
|
+
this.sections = null;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.sections = MsgCallArgSections.readWithCount(r, length);
|
|
72
|
+
this.args = new Uint8Array();
|
|
19
73
|
}
|
|
20
74
|
static read(r) {
|
|
21
75
|
const v = new TxMsgCall();
|
|
@@ -1,18 +1,71 @@
|
|
|
1
|
+
import { Throw } from '../../CarbonSerialization';
|
|
2
|
+
export class MsgCallArgSections {
|
|
3
|
+
constructor(argSections = []) {
|
|
4
|
+
this.argSections = argSections;
|
|
5
|
+
}
|
|
6
|
+
hasSections() {
|
|
7
|
+
return this.argSections.length > 0;
|
|
8
|
+
}
|
|
9
|
+
write(w) {
|
|
10
|
+
Throw.Assert(this.argSections.length > 0, 'arg sections are empty');
|
|
11
|
+
w.write4(-this.argSections.length);
|
|
12
|
+
for (const section of this.argSections) {
|
|
13
|
+
if (section.registerOffset < 0) {
|
|
14
|
+
w.write4(section.registerOffset);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
w.write4(section.args.length);
|
|
18
|
+
if (section.args.length > 0) {
|
|
19
|
+
w.write(section.args);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
static readWithCount(r, countNegative) {
|
|
24
|
+
Throw.Assert(countNegative < 0, 'arg sections count must be negative');
|
|
25
|
+
const length = -countNegative;
|
|
26
|
+
const sections = new Array(length);
|
|
27
|
+
for (let i = 0; i < length; i++) {
|
|
28
|
+
const value = r.read4();
|
|
29
|
+
if (value < 0) {
|
|
30
|
+
sections[i] = { registerOffset: value, args: new Uint8Array() };
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const args = r.readExactly(value);
|
|
34
|
+
sections[i] = { registerOffset: 0, args };
|
|
35
|
+
}
|
|
36
|
+
return new MsgCallArgSections(sections);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
1
39
|
export class TxMsgCall {
|
|
2
40
|
constructor(moduleId = 0, methodId = 0, args = new Uint8Array()) {
|
|
3
41
|
this.moduleId = moduleId >>> 0;
|
|
4
42
|
this.methodId = methodId >>> 0;
|
|
5
43
|
this.args = args;
|
|
44
|
+
this.sections = null;
|
|
6
45
|
}
|
|
7
46
|
write(w) {
|
|
8
47
|
w.write4u(this.moduleId);
|
|
9
48
|
w.write4u(this.methodId);
|
|
10
|
-
|
|
49
|
+
if (this.sections && this.sections.hasSections()) {
|
|
50
|
+
this.sections.write(w);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
w.write4(this.args.length);
|
|
54
|
+
if (this.args.length > 0) {
|
|
55
|
+
w.write(this.args);
|
|
56
|
+
}
|
|
11
57
|
}
|
|
12
58
|
read(r) {
|
|
13
59
|
this.moduleId = r.read4u();
|
|
14
60
|
this.methodId = r.read4u();
|
|
15
|
-
|
|
61
|
+
const length = r.read4();
|
|
62
|
+
if (length >= 0) {
|
|
63
|
+
this.args = r.readExactly(length);
|
|
64
|
+
this.sections = null;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.sections = MsgCallArgSections.readWithCount(r, length);
|
|
68
|
+
this.args = new Uint8Array();
|
|
16
69
|
}
|
|
17
70
|
static read(r) {
|
|
18
71
|
const v = new TxMsgCall();
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { ICarbonBlob } from '../../../interfaces/Carbon/ICarbonBlob';
|
|
2
2
|
import { CarbonBinaryReader, CarbonBinaryWriter } from '../../CarbonSerialization';
|
|
3
|
+
export type MsgCallArgs = {
|
|
4
|
+
registerOffset: number;
|
|
5
|
+
args: Uint8Array;
|
|
6
|
+
};
|
|
7
|
+
export declare class MsgCallArgSections {
|
|
8
|
+
argSections: MsgCallArgs[];
|
|
9
|
+
constructor(argSections?: MsgCallArgs[]);
|
|
10
|
+
hasSections(): boolean;
|
|
11
|
+
write(w: CarbonBinaryWriter): void;
|
|
12
|
+
static readWithCount(r: CarbonBinaryReader, countNegative: number): MsgCallArgSections;
|
|
13
|
+
}
|
|
3
14
|
export declare class TxMsgCall implements ICarbonBlob {
|
|
4
15
|
moduleId: number;
|
|
5
16
|
methodId: number;
|
|
6
17
|
args: Uint8Array;
|
|
18
|
+
sections: MsgCallArgSections | null;
|
|
7
19
|
constructor(moduleId?: number, methodId?: number, args?: Uint8Array);
|
|
8
20
|
write(w: CarbonBinaryWriter): void;
|
|
9
21
|
read(r: CarbonBinaryReader): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxMsgCall.d.ts","sourceRoot":"","sources":["../../../../../../src/core/types/Carbon/Blockchain/TxMsgCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"TxMsgCall.d.ts","sourceRoot":"","sources":["../../../../../../src/core/types/Carbon/Blockchain/TxMsgCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAS,MAAM,2BAA2B,CAAC;AAE1F,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,qBAAa,kBAAkB;IAC7B,WAAW,EAAE,WAAW,EAAE,CAAC;gBAEf,WAAW,GAAE,WAAW,EAAO;IAI3C,WAAW,IAAI,OAAO;IAItB,KAAK,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAelC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,GAAG,kBAAkB;CAevF;AAED,qBAAa,SAAU,YAAW,WAAW;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;gBAExB,QAAQ,GAAE,MAAU,EAAE,QAAQ,GAAE,MAAU,EAAE,IAAI,GAAE,UAA6B;IAO3F,KAAK,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAalC,IAAI,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAajC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,kBAAkB,GAAG,SAAS;CAK9C"}
|