pshenmic-dpp 1.0.0 → 1.0.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/Cargo.lock +54 -17
- package/Cargo.toml +10 -3
- package/README.md +3 -0
- package/dist/wasm/pshenmic_dpp.js +508 -40
- package/package.json +3 -4
- package/packages/cbor-conversation/Cargo.toml +6 -2
- package/packages/cbor-conversation/src/lib.rs +1 -3
- package/packages/document/Cargo.toml +4 -0
- package/packages/document_batch/Cargo.toml +6 -2
- package/packages/document_batch/src/lib.rs +88 -187
- package/packages/enums/Cargo.toml +5 -1
- package/packages/identity/Cargo.toml +17 -0
- package/packages/identity/src/lib.rs +77 -0
- package/packages/identity_transitions/Cargo.toml +21 -0
- package/packages/identity_transitions/src/create_transition/mod.rs +99 -0
- package/packages/identity_transitions/src/create_transition/public_key_in_creation/mod.rs +146 -0
- package/packages/identity_transitions/src/lib.rs +1 -0
- package/packages/mock_bls/Cargo.toml +5 -1
- package/packages/private_key/Cargo.toml +5 -1
- package/packages/private_key/src/lib.rs +14 -17
- package/packages/public_key/Cargo.toml +7 -3
- package/packages/public_key/src/lib.rs +58 -38
- package/packages/state_transition/Cargo.toml +22 -0
- package/packages/state_transition/src/lib.rs +95 -0
- package/packages/utils/Cargo.toml +4 -0
- package/scripts/build.sh +2 -3
- package/src/lib.rs +3 -0
|
@@ -172,12 +172,6 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
172
172
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
function _assertClass(instance, klass) {
|
|
176
|
-
if (!(instance instanceof klass)) {
|
|
177
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
175
|
function takeFromExternrefTable0(idx) {
|
|
182
176
|
const value = wasm.__wbindgen_export_2.get(idx);
|
|
183
177
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -190,6 +184,23 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
190
184
|
WASM_VECTOR_LEN = arg.length;
|
|
191
185
|
return ptr;
|
|
192
186
|
}
|
|
187
|
+
|
|
188
|
+
function _assertClass(instance, klass) {
|
|
189
|
+
if (!(instance instanceof klass)) {
|
|
190
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
195
|
+
ptr = ptr >>> 0;
|
|
196
|
+
const mem = getDataViewMemory0();
|
|
197
|
+
const result = [];
|
|
198
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
199
|
+
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
200
|
+
}
|
|
201
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
193
204
|
/**
|
|
194
205
|
* @param {any} object
|
|
195
206
|
* @returns {string}
|
|
@@ -299,50 +310,43 @@ export class DocumentBatchWASM {
|
|
|
299
310
|
return DocumentBatchWASM.__wrap(ret[0]);
|
|
300
311
|
}
|
|
301
312
|
/**
|
|
302
|
-
* @
|
|
303
|
-
|
|
313
|
+
* @returns {StateTransitionWASM}
|
|
314
|
+
*/
|
|
315
|
+
toStateTransition() {
|
|
316
|
+
const ret = wasm.documentbatchwasm_toStateTransition(this.__wbg_ptr);
|
|
317
|
+
return StateTransitionWASM.__wrap(ret);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
304
320
|
* @returns {any}
|
|
305
321
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var ptr0 = private_key.__destroy_into_raw();
|
|
309
|
-
_assertClass(public_key, IdentityPublicKeyWASM);
|
|
310
|
-
var ptr1 = public_key.__destroy_into_raw();
|
|
311
|
-
const ret = wasm.documentbatchwasm_sign(this.__wbg_ptr, ptr0, ptr1);
|
|
322
|
+
toBuffer() {
|
|
323
|
+
const ret = wasm.documentbatchwasm_toBuffer(this.__wbg_ptr);
|
|
312
324
|
if (ret[2]) {
|
|
313
325
|
throw takeFromExternrefTable0(ret[1]);
|
|
314
326
|
}
|
|
315
327
|
return takeFromExternrefTable0(ret[0]);
|
|
316
328
|
}
|
|
317
329
|
/**
|
|
318
|
-
* @param {
|
|
319
|
-
* @
|
|
320
|
-
* @returns {any}
|
|
321
|
-
*/
|
|
322
|
-
signByPrivateKey(private_key, key_type) {
|
|
323
|
-
_assertClass(private_key, PrivateKeyWASM);
|
|
324
|
-
var ptr0 = private_key.__destroy_into_raw();
|
|
325
|
-
const ret = wasm.documentbatchwasm_signByPrivateKey(this.__wbg_ptr, ptr0, key_type);
|
|
326
|
-
return ret;
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* @returns {any}
|
|
330
|
+
* @param {StateTransitionWASM} state_transition
|
|
331
|
+
* @returns {DocumentBatchWASM}
|
|
330
332
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
static fromStateTransition(state_transition) {
|
|
334
|
+
_assertClass(state_transition, StateTransitionWASM);
|
|
335
|
+
var ptr0 = state_transition.__destroy_into_raw();
|
|
336
|
+
const ret = wasm.documentbatchwasm_fromStateTransition(ptr0);
|
|
333
337
|
if (ret[2]) {
|
|
334
338
|
throw takeFromExternrefTable0(ret[1]);
|
|
335
339
|
}
|
|
336
|
-
return
|
|
340
|
+
return DocumentBatchWASM.__wrap(ret[0]);
|
|
337
341
|
}
|
|
338
342
|
/**
|
|
339
343
|
* @param {Uint8Array} bytes
|
|
340
344
|
* @returns {DocumentBatchWASM}
|
|
341
345
|
*/
|
|
342
|
-
static
|
|
346
|
+
static from_buffer(bytes) {
|
|
343
347
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
344
348
|
const len0 = WASM_VECTOR_LEN;
|
|
345
|
-
const ret = wasm.
|
|
349
|
+
const ret = wasm.documentbatchwasm_from_buffer(ptr0, len0);
|
|
346
350
|
if (ret[2]) {
|
|
347
351
|
throw takeFromExternrefTable0(ret[1]);
|
|
348
352
|
}
|
|
@@ -616,6 +620,254 @@ export class DocumentWASM {
|
|
|
616
620
|
}
|
|
617
621
|
}
|
|
618
622
|
|
|
623
|
+
const IdentityCreateTransitionWASMFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
624
|
+
? { register: () => {}, unregister: () => {} }
|
|
625
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_identitycreatetransitionwasm_free(ptr >>> 0, 1));
|
|
626
|
+
|
|
627
|
+
export class IdentityCreateTransitionWASM {
|
|
628
|
+
|
|
629
|
+
static __wrap(ptr) {
|
|
630
|
+
ptr = ptr >>> 0;
|
|
631
|
+
const obj = Object.create(IdentityCreateTransitionWASM.prototype);
|
|
632
|
+
obj.__wbg_ptr = ptr;
|
|
633
|
+
IdentityCreateTransitionWASMFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
634
|
+
return obj;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
__destroy_into_raw() {
|
|
638
|
+
const ptr = this.__wbg_ptr;
|
|
639
|
+
this.__wbg_ptr = 0;
|
|
640
|
+
IdentityCreateTransitionWASMFinalization.unregister(this);
|
|
641
|
+
return ptr;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
free() {
|
|
645
|
+
const ptr = this.__destroy_into_raw();
|
|
646
|
+
wasm.__wbg_identitycreatetransitionwasm_free(ptr, 0);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* @param {number} platform_version
|
|
650
|
+
*/
|
|
651
|
+
constructor(platform_version) {
|
|
652
|
+
const ret = wasm.identitycreatetransitionwasm_new(platform_version);
|
|
653
|
+
if (ret[2]) {
|
|
654
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
655
|
+
}
|
|
656
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
657
|
+
IdentityCreateTransitionWASMFinalization.register(this, this.__wbg_ptr, this);
|
|
658
|
+
return this;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* @returns {IdentityPublicKeyInCreationWASM[]}
|
|
662
|
+
*/
|
|
663
|
+
defaultVersioned() {
|
|
664
|
+
const ret = wasm.identitycreatetransitionwasm_defaultVersioned(this.__wbg_ptr);
|
|
665
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
666
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
667
|
+
return v1;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* @returns {string}
|
|
671
|
+
*/
|
|
672
|
+
getIdentifier() {
|
|
673
|
+
let deferred1_0;
|
|
674
|
+
let deferred1_1;
|
|
675
|
+
try {
|
|
676
|
+
const ret = wasm.identitycreatetransitionwasm_getIdentifier(this.__wbg_ptr);
|
|
677
|
+
deferred1_0 = ret[0];
|
|
678
|
+
deferred1_1 = ret[1];
|
|
679
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
680
|
+
} finally {
|
|
681
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* @returns {number}
|
|
686
|
+
*/
|
|
687
|
+
getUserFeeIncrease() {
|
|
688
|
+
const ret = wasm.identitycreatetransitionwasm_getUserFeeIncrease(this.__wbg_ptr);
|
|
689
|
+
return ret;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* @returns {StateTransitionWASM}
|
|
693
|
+
*/
|
|
694
|
+
toStateTransition() {
|
|
695
|
+
const ret = wasm.identitycreatetransitionwasm_toStateTransition(this.__wbg_ptr);
|
|
696
|
+
return StateTransitionWASM.__wrap(ret);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* @returns {any}
|
|
700
|
+
*/
|
|
701
|
+
toBuffer() {
|
|
702
|
+
const ret = wasm.identitycreatetransitionwasm_toBuffer(this.__wbg_ptr);
|
|
703
|
+
if (ret[2]) {
|
|
704
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
705
|
+
}
|
|
706
|
+
return takeFromExternrefTable0(ret[0]);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* @param {StateTransitionWASM} st
|
|
710
|
+
* @returns {IdentityCreateTransitionWASM}
|
|
711
|
+
*/
|
|
712
|
+
static fromStateTransition(st) {
|
|
713
|
+
_assertClass(st, StateTransitionWASM);
|
|
714
|
+
var ptr0 = st.__destroy_into_raw();
|
|
715
|
+
const ret = wasm.identitycreatetransitionwasm_fromStateTransition(ptr0);
|
|
716
|
+
if (ret[2]) {
|
|
717
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
718
|
+
}
|
|
719
|
+
return IdentityCreateTransitionWASM.__wrap(ret[0]);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* @param {Uint8Array} bytes
|
|
723
|
+
* @returns {IdentityCreateTransitionWASM}
|
|
724
|
+
*/
|
|
725
|
+
static fromBuffer(bytes) {
|
|
726
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
727
|
+
const len0 = WASM_VECTOR_LEN;
|
|
728
|
+
const ret = wasm.identitycreatetransitionwasm_fromBuffer(ptr0, len0);
|
|
729
|
+
if (ret[2]) {
|
|
730
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
731
|
+
}
|
|
732
|
+
return IdentityCreateTransitionWASM.__wrap(ret[0]);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
const IdentityPublicKeyInCreationWASMFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
737
|
+
? { register: () => {}, unregister: () => {} }
|
|
738
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_identitypublickeyincreationwasm_free(ptr >>> 0, 1));
|
|
739
|
+
|
|
740
|
+
export class IdentityPublicKeyInCreationWASM {
|
|
741
|
+
|
|
742
|
+
static __wrap(ptr) {
|
|
743
|
+
ptr = ptr >>> 0;
|
|
744
|
+
const obj = Object.create(IdentityPublicKeyInCreationWASM.prototype);
|
|
745
|
+
obj.__wbg_ptr = ptr;
|
|
746
|
+
IdentityPublicKeyInCreationWASMFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
747
|
+
return obj;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
__destroy_into_raw() {
|
|
751
|
+
const ptr = this.__wbg_ptr;
|
|
752
|
+
this.__wbg_ptr = 0;
|
|
753
|
+
IdentityPublicKeyInCreationWASMFinalization.unregister(this);
|
|
754
|
+
return ptr;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
free() {
|
|
758
|
+
const ptr = this.__destroy_into_raw();
|
|
759
|
+
wasm.__wbg_identitypublickeyincreationwasm_free(ptr, 0);
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* @param {number} id
|
|
763
|
+
* @param {Purpose} purpose
|
|
764
|
+
* @param {SecurityLevel} security_level
|
|
765
|
+
* @param {KeyType} key_type
|
|
766
|
+
* @param {boolean} read_only
|
|
767
|
+
* @param {string} binary_data
|
|
768
|
+
* @param {string} signature
|
|
769
|
+
*/
|
|
770
|
+
constructor(id, purpose, security_level, key_type, read_only, binary_data, signature) {
|
|
771
|
+
const ptr0 = passStringToWasm0(binary_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
772
|
+
const len0 = WASM_VECTOR_LEN;
|
|
773
|
+
const ptr1 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
774
|
+
const len1 = WASM_VECTOR_LEN;
|
|
775
|
+
const ret = wasm.identitypublickeyincreationwasm_new(id, purpose, security_level, key_type, read_only, ptr0, len0, ptr1, len1);
|
|
776
|
+
this.__wbg_ptr = ret >>> 0;
|
|
777
|
+
IdentityPublicKeyInCreationWASMFinalization.register(this, this.__wbg_ptr, this);
|
|
778
|
+
return this;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* @returns {IdentityPublicKeyWASM}
|
|
782
|
+
*/
|
|
783
|
+
toIdentityPublicKey() {
|
|
784
|
+
const ret = wasm.identitypublickeyincreationwasm_toIdentityPublicKey(this.__wbg_ptr);
|
|
785
|
+
return IdentityPublicKeyWASM.__wrap(ret);
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* @returns {number}
|
|
789
|
+
*/
|
|
790
|
+
getKeyId() {
|
|
791
|
+
const ret = wasm.identitypublickeyincreationwasm_getKeyId(this.__wbg_ptr);
|
|
792
|
+
return ret >>> 0;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* @returns {Purpose}
|
|
796
|
+
*/
|
|
797
|
+
getPurpose() {
|
|
798
|
+
const ret = wasm.identitypublickeyincreationwasm_getPurpose(this.__wbg_ptr);
|
|
799
|
+
return ret;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* @returns {SecurityLevel}
|
|
803
|
+
*/
|
|
804
|
+
getSecurityLevel() {
|
|
805
|
+
const ret = wasm.identitypublickeyincreationwasm_getSecurityLevel(this.__wbg_ptr);
|
|
806
|
+
return ret;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* @returns {KeyType}
|
|
810
|
+
*/
|
|
811
|
+
getKeyType() {
|
|
812
|
+
const ret = wasm.identitypublickeyincreationwasm_getKeyType(this.__wbg_ptr);
|
|
813
|
+
return ret;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* @returns {boolean}
|
|
817
|
+
*/
|
|
818
|
+
getReadOnly() {
|
|
819
|
+
const ret = wasm.identitypublickeyincreationwasm_getReadOnly(this.__wbg_ptr);
|
|
820
|
+
return ret !== 0;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* @returns {string}
|
|
824
|
+
*/
|
|
825
|
+
getData() {
|
|
826
|
+
let deferred1_0;
|
|
827
|
+
let deferred1_1;
|
|
828
|
+
try {
|
|
829
|
+
const ret = wasm.identitypublickeyincreationwasm_getData(this.__wbg_ptr);
|
|
830
|
+
deferred1_0 = ret[0];
|
|
831
|
+
deferred1_1 = ret[1];
|
|
832
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
833
|
+
} finally {
|
|
834
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* @param {number} key_id
|
|
839
|
+
*/
|
|
840
|
+
setKeyId(key_id) {
|
|
841
|
+
wasm.identitypublickeyincreationwasm_setKeyId(this.__wbg_ptr, key_id);
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* @param {Purpose} purpose
|
|
845
|
+
*/
|
|
846
|
+
setPurpose(purpose) {
|
|
847
|
+
wasm.identitypublickeyincreationwasm_setPurpose(this.__wbg_ptr, purpose);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* @param {SecurityLevel} security_level
|
|
851
|
+
*/
|
|
852
|
+
setSecurityLevel(security_level) {
|
|
853
|
+
wasm.identitypublickeyincreationwasm_setSecurityLevel(this.__wbg_ptr, security_level);
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* @param {boolean} read_only
|
|
857
|
+
*/
|
|
858
|
+
setReadOnly(read_only) {
|
|
859
|
+
wasm.identitypublickeyincreationwasm_setReadOnly(this.__wbg_ptr, read_only);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* @param {string} binary_data
|
|
863
|
+
*/
|
|
864
|
+
setData(binary_data) {
|
|
865
|
+
const ptr0 = passStringToWasm0(binary_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
866
|
+
const len0 = WASM_VECTOR_LEN;
|
|
867
|
+
wasm.identitypublickeyincreationwasm_setData(this.__wbg_ptr, ptr0, len0);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
619
871
|
const IdentityPublicKeyWASMFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
620
872
|
? { register: () => {}, unregister: () => {} }
|
|
621
873
|
: new FinalizationRegistry(ptr => wasm.__wbg_identitypublickeywasm_free(ptr >>> 0, 1));
|
|
@@ -649,13 +901,14 @@ export class IdentityPublicKeyWASM {
|
|
|
649
901
|
* @param {boolean} read_only
|
|
650
902
|
* @param {string} binary_data
|
|
651
903
|
* @param {bigint | null} [disabled_at]
|
|
652
|
-
* @returns {IdentityPublicKeyWASM}
|
|
653
904
|
*/
|
|
654
|
-
|
|
905
|
+
constructor(id, purpose, security_level, key_type, read_only, binary_data, disabled_at) {
|
|
655
906
|
const ptr0 = passStringToWasm0(binary_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
656
907
|
const len0 = WASM_VECTOR_LEN;
|
|
657
908
|
const ret = wasm.identitypublickeywasm_new(id, purpose, security_level, key_type, read_only, ptr0, len0, !isLikeNone(disabled_at), isLikeNone(disabled_at) ? BigInt(0) : disabled_at);
|
|
658
|
-
|
|
909
|
+
this.__wbg_ptr = ret >>> 0;
|
|
910
|
+
IdentityPublicKeyWASMFinalization.register(this, this.__wbg_ptr, this);
|
|
911
|
+
return this;
|
|
659
912
|
}
|
|
660
913
|
/**
|
|
661
914
|
* @returns {number}
|
|
@@ -758,6 +1011,133 @@ export class IdentityPublicKeyWASM {
|
|
|
758
1011
|
setDisabledAt(disabled_at) {
|
|
759
1012
|
wasm.identitypublickeywasm_setDisabledAt(this.__wbg_ptr, disabled_at);
|
|
760
1013
|
}
|
|
1014
|
+
/**
|
|
1015
|
+
* @returns {Uint8Array}
|
|
1016
|
+
*/
|
|
1017
|
+
toBuffer() {
|
|
1018
|
+
const ret = wasm.identitypublickeywasm_toBuffer(this.__wbg_ptr);
|
|
1019
|
+
if (ret[3]) {
|
|
1020
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1021
|
+
}
|
|
1022
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1023
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1024
|
+
return v1;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* @param {Uint8Array} buffer
|
|
1028
|
+
* @returns {IdentityPublicKeyWASM}
|
|
1029
|
+
*/
|
|
1030
|
+
static fromBuffer(buffer) {
|
|
1031
|
+
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
1032
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1033
|
+
const ret = wasm.identitypublickeywasm_fromBuffer(ptr0, len0);
|
|
1034
|
+
if (ret[2]) {
|
|
1035
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1036
|
+
}
|
|
1037
|
+
return IdentityPublicKeyWASM.__wrap(ret[0]);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
const IdentityWASMFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1042
|
+
? { register: () => {}, unregister: () => {} }
|
|
1043
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_identitywasm_free(ptr >>> 0, 1));
|
|
1044
|
+
|
|
1045
|
+
export class IdentityWASM {
|
|
1046
|
+
|
|
1047
|
+
__destroy_into_raw() {
|
|
1048
|
+
const ptr = this.__wbg_ptr;
|
|
1049
|
+
this.__wbg_ptr = 0;
|
|
1050
|
+
IdentityWASMFinalization.unregister(this);
|
|
1051
|
+
return ptr;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
free() {
|
|
1055
|
+
const ptr = this.__destroy_into_raw();
|
|
1056
|
+
wasm.__wbg_identitywasm_free(ptr, 0);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* @param {string} js_identifier
|
|
1060
|
+
*/
|
|
1061
|
+
constructor(js_identifier) {
|
|
1062
|
+
const ptr0 = passStringToWasm0(js_identifier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1063
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1064
|
+
const ret = wasm.identitywasm_new(ptr0, len0);
|
|
1065
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1066
|
+
IdentityWASMFinalization.register(this, this.__wbg_ptr, this);
|
|
1067
|
+
return this;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* @param {string} js_identifier
|
|
1071
|
+
*/
|
|
1072
|
+
setId(js_identifier) {
|
|
1073
|
+
const ptr0 = passStringToWasm0(js_identifier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1074
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1075
|
+
wasm.identitywasm_setId(this.__wbg_ptr, ptr0, len0);
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* @param {bigint} balance
|
|
1079
|
+
*/
|
|
1080
|
+
setBalance(balance) {
|
|
1081
|
+
wasm.identitywasm_setBalance(this.__wbg_ptr, balance);
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* @param {bigint} revision
|
|
1085
|
+
*/
|
|
1086
|
+
setRevision(revision) {
|
|
1087
|
+
wasm.identitywasm_setRevision(this.__wbg_ptr, revision);
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* @param {IdentityPublicKeyWASM} public_key
|
|
1091
|
+
*/
|
|
1092
|
+
addPublicKey(public_key) {
|
|
1093
|
+
_assertClass(public_key, IdentityPublicKeyWASM);
|
|
1094
|
+
var ptr0 = public_key.__destroy_into_raw();
|
|
1095
|
+
wasm.identitywasm_addPublicKey(this.__wbg_ptr, ptr0);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* @returns {string}
|
|
1099
|
+
*/
|
|
1100
|
+
getId() {
|
|
1101
|
+
let deferred1_0;
|
|
1102
|
+
let deferred1_1;
|
|
1103
|
+
try {
|
|
1104
|
+
const ret = wasm.identitywasm_getId(this.__wbg_ptr);
|
|
1105
|
+
deferred1_0 = ret[0];
|
|
1106
|
+
deferred1_1 = ret[1];
|
|
1107
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1108
|
+
} finally {
|
|
1109
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* @returns {bigint}
|
|
1114
|
+
*/
|
|
1115
|
+
getBalance() {
|
|
1116
|
+
const ret = wasm.identitywasm_getBalance(this.__wbg_ptr);
|
|
1117
|
+
return BigInt.asUintN(64, ret);
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* @returns {bigint}
|
|
1121
|
+
*/
|
|
1122
|
+
getRevision() {
|
|
1123
|
+
const ret = wasm.identitywasm_getRevision(this.__wbg_ptr);
|
|
1124
|
+
return BigInt.asUintN(64, ret);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* @param {number} key_id
|
|
1128
|
+
* @returns {IdentityPublicKeyWASM}
|
|
1129
|
+
*/
|
|
1130
|
+
getPublicKeyById(key_id) {
|
|
1131
|
+
const ret = wasm.identitywasm_getPublicKeyById(this.__wbg_ptr, key_id);
|
|
1132
|
+
return IdentityPublicKeyWASM.__wrap(ret);
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* @returns {any}
|
|
1136
|
+
*/
|
|
1137
|
+
getPublicKeys() {
|
|
1138
|
+
const ret = wasm.identitywasm_getPublicKeys(this.__wbg_ptr);
|
|
1139
|
+
return ret;
|
|
1140
|
+
}
|
|
761
1141
|
}
|
|
762
1142
|
|
|
763
1143
|
const PrivateKeyWASMFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -793,7 +1173,10 @@ export class PrivateKeyWASM {
|
|
|
793
1173
|
const ptr0 = passStringToWasm0(wif, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
794
1174
|
const len0 = WASM_VECTOR_LEN;
|
|
795
1175
|
const ret = wasm.privatekeywasm_new(ptr0, len0);
|
|
796
|
-
|
|
1176
|
+
if (ret[2]) {
|
|
1177
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1178
|
+
}
|
|
1179
|
+
return PrivateKeyWASM.__wrap(ret[0]);
|
|
797
1180
|
}
|
|
798
1181
|
/**
|
|
799
1182
|
* @returns {string}
|
|
@@ -810,6 +1193,92 @@ export class PrivateKeyWASM {
|
|
|
810
1193
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
811
1194
|
}
|
|
812
1195
|
}
|
|
1196
|
+
/**
|
|
1197
|
+
* @returns {Uint8Array}
|
|
1198
|
+
*/
|
|
1199
|
+
getKeyBytes() {
|
|
1200
|
+
const ret = wasm.privatekeywasm_getKeyBytes(this.__wbg_ptr);
|
|
1201
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1202
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1203
|
+
return v1;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
const StateTransitionWASMFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1208
|
+
? { register: () => {}, unregister: () => {} }
|
|
1209
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_statetransitionwasm_free(ptr >>> 0, 1));
|
|
1210
|
+
|
|
1211
|
+
export class StateTransitionWASM {
|
|
1212
|
+
|
|
1213
|
+
static __wrap(ptr) {
|
|
1214
|
+
ptr = ptr >>> 0;
|
|
1215
|
+
const obj = Object.create(StateTransitionWASM.prototype);
|
|
1216
|
+
obj.__wbg_ptr = ptr;
|
|
1217
|
+
StateTransitionWASMFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1218
|
+
return obj;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
__destroy_into_raw() {
|
|
1222
|
+
const ptr = this.__wbg_ptr;
|
|
1223
|
+
this.__wbg_ptr = 0;
|
|
1224
|
+
StateTransitionWASMFinalization.unregister(this);
|
|
1225
|
+
return ptr;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
free() {
|
|
1229
|
+
const ptr = this.__destroy_into_raw();
|
|
1230
|
+
wasm.__wbg_statetransitionwasm_free(ptr, 0);
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* @param {PrivateKeyWASM} private_key
|
|
1234
|
+
* @param {IdentityPublicKeyWASM} public_key
|
|
1235
|
+
* @returns {any}
|
|
1236
|
+
*/
|
|
1237
|
+
sign(private_key, public_key) {
|
|
1238
|
+
_assertClass(private_key, PrivateKeyWASM);
|
|
1239
|
+
var ptr0 = private_key.__destroy_into_raw();
|
|
1240
|
+
_assertClass(public_key, IdentityPublicKeyWASM);
|
|
1241
|
+
var ptr1 = public_key.__destroy_into_raw();
|
|
1242
|
+
const ret = wasm.statetransitionwasm_sign(this.__wbg_ptr, ptr0, ptr1);
|
|
1243
|
+
if (ret[2]) {
|
|
1244
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1245
|
+
}
|
|
1246
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* @param {PrivateKeyWASM} private_key
|
|
1250
|
+
* @param {KeyType} key_type
|
|
1251
|
+
* @returns {any}
|
|
1252
|
+
*/
|
|
1253
|
+
signByPrivateKey(private_key, key_type) {
|
|
1254
|
+
_assertClass(private_key, PrivateKeyWASM);
|
|
1255
|
+
var ptr0 = private_key.__destroy_into_raw();
|
|
1256
|
+
const ret = wasm.statetransitionwasm_signByPrivateKey(this.__wbg_ptr, ptr0, key_type);
|
|
1257
|
+
return ret;
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* @returns {any}
|
|
1261
|
+
*/
|
|
1262
|
+
toBuffer() {
|
|
1263
|
+
const ret = wasm.statetransitionwasm_toBuffer(this.__wbg_ptr);
|
|
1264
|
+
if (ret[2]) {
|
|
1265
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1266
|
+
}
|
|
1267
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* @param {Uint8Array} buffer
|
|
1271
|
+
* @returns {StateTransitionWASM}
|
|
1272
|
+
*/
|
|
1273
|
+
static from_buffer(buffer) {
|
|
1274
|
+
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
1275
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1276
|
+
const ret = wasm.statetransitionwasm_from_buffer(ptr0, len0);
|
|
1277
|
+
if (ret[2]) {
|
|
1278
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1279
|
+
}
|
|
1280
|
+
return StateTransitionWASM.__wrap(ret[0]);
|
|
1281
|
+
}
|
|
813
1282
|
}
|
|
814
1283
|
|
|
815
1284
|
async function __wbg_load(module, imports) {
|
|
@@ -869,6 +1338,10 @@ function __wbg_get_imports() {
|
|
|
869
1338
|
imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
|
|
870
1339
|
arg0.getRandomValues(arg1);
|
|
871
1340
|
}, arguments) };
|
|
1341
|
+
imports.wbg.__wbg_identitypublickeyincreationwasm_new = function(arg0) {
|
|
1342
|
+
const ret = IdentityPublicKeyInCreationWASM.__wrap(arg0);
|
|
1343
|
+
return ret;
|
|
1344
|
+
};
|
|
872
1345
|
imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
|
|
873
1346
|
const ret = arg0.msCrypto;
|
|
874
1347
|
return ret;
|
|
@@ -977,11 +1450,6 @@ function __wbg_get_imports() {
|
|
|
977
1450
|
const ret = BigInt.asUintN(64, arg0);
|
|
978
1451
|
return ret;
|
|
979
1452
|
};
|
|
980
|
-
imports.wbg.__wbindgen_boolean_get = function(arg0) {
|
|
981
|
-
const v = arg0;
|
|
982
|
-
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
983
|
-
return ret;
|
|
984
|
-
};
|
|
985
1453
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
986
1454
|
const ret = debugString(arg1);
|
|
987
1455
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pshenmic-dpp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "dist/wasm/pshenmic_dpp.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/owl352/
|
|
7
|
+
"url": "https://github.com/owl352/pshenmic-dpp"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"tsc": "tsc",
|
|
@@ -20,6 +20,5 @@
|
|
|
20
20
|
"babel": "^6.23.0",
|
|
21
21
|
"babel-cli": "^6.26.0",
|
|
22
22
|
"typescript": "^5.8.2"
|
|
23
|
-
}
|
|
24
|
-
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
|
23
|
+
}
|
|
25
24
|
}
|
|
@@ -9,9 +9,13 @@ crate-type = ["cdylib", "lib"]
|
|
|
9
9
|
[dependencies]
|
|
10
10
|
wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] }
|
|
11
11
|
dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
|
|
12
|
-
"cbor"
|
|
12
|
+
"cbor",
|
|
13
13
|
]}
|
|
14
14
|
pshenmic_dpp_utils = {path = "../utils"}
|
|
15
15
|
base64 = "0.22.1"
|
|
16
|
-
ciborium = "0.2.
|
|
16
|
+
ciborium = "0.2.2"
|
|
17
17
|
serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
|
|
18
|
+
|
|
19
|
+
[profile.release]
|
|
20
|
+
lto = true
|
|
21
|
+
opt-level = 'z'
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
use base64::Engine;
|
|
2
2
|
use base64::prelude::BASE64_STANDARD;
|
|
3
|
-
use ciborium;
|
|
4
|
-
use ciborium::Value;
|
|
5
3
|
use dpp::util::cbor_serializer::serializable_value_to_cbor;
|
|
6
4
|
use pshenmic_dpp_utils::with_serde_to_platform_value;
|
|
7
5
|
use wasm_bindgen::JsValue;
|
|
@@ -20,7 +18,7 @@ pub fn object_to_cbor(object: &JsValue) -> String {
|
|
|
20
18
|
pub fn cbor_to_object(cbor: String) -> JsValue {
|
|
21
19
|
let base64_bytes = BASE64_STANDARD.decode(cbor).unwrap();
|
|
22
20
|
|
|
23
|
-
let cbor: Value = ciborium::de::from_reader(base64_bytes.as_slice()).expect("REASON");
|
|
21
|
+
let cbor: ciborium::Value = ciborium::de::from_reader(base64_bytes.as_slice()).expect("REASON");
|
|
24
22
|
|
|
25
23
|
serde_wasm_bindgen::to_value(&cbor).unwrap()
|
|
26
24
|
}
|
|
@@ -13,3 +13,7 @@ dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-
|
|
|
13
13
|
"document-json-conversion"
|
|
14
14
|
]}
|
|
15
15
|
serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
|
|
16
|
+
|
|
17
|
+
[profile.release]
|
|
18
|
+
lto = true
|
|
19
|
+
opt-level = 'z'
|