fix: isomorhpic randomUUID
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { InteractionData } from './modules/impl/HandlerExecutorFactory';
|
||||
import { InnerCallType } from '../contract/Contract';
|
||||
import { isomorphicRandomUUID } from '../utils/utils';
|
||||
|
||||
export class ContractCallRecord {
|
||||
readonly interactions: { [key: string]: InteractionCall } = {};
|
||||
readonly id: string;
|
||||
|
||||
constructor(readonly contractTxId: string, readonly depth: number, readonly innerCallType: InnerCallType = null) {}
|
||||
constructor(readonly contractTxId: string, readonly depth: number, readonly innerCallType: InnerCallType = null) {
|
||||
this.id = isomorphicRandomUUID();
|
||||
}
|
||||
|
||||
addInteractionData(interactionData: InteractionData<any>): InteractionCall {
|
||||
const { interaction, interactionTx } = interactionData;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* eslint-disable */
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import copy from 'fast-copy';
|
||||
import { Buffer } from 'redstone-isomorphic';
|
||||
import {Buffer} from 'redstone-isomorphic';
|
||||
import {randomUUID} from "crypto";
|
||||
|
||||
export const sleep = (ms: number): Promise<void> => {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
@@ -75,3 +76,11 @@ export function bufToBn(buf: Buffer) {
|
||||
|
||||
return BigInt('0x' + hex.join(''));
|
||||
}
|
||||
|
||||
export function isomorphicRandomUUID() {
|
||||
if (self.crypto) {
|
||||
return self.crypto.randomUUID();
|
||||
} else {
|
||||
return randomUUID();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user