Comparing version 0.1.0-rc.3 to 0.1.0-rc.4
@@ -10,3 +10,3 @@ "use strict"; | ||
function abiEncode(schema, obj, encoder) { | ||
encoder = (encoder !== null && encoder !== void 0 ? encoder : new Encoder()); | ||
encoder = encoder !== null && encoder !== void 0 ? encoder : new Encoder(); | ||
doAbiEncode(schema, obj, encoder); | ||
@@ -206,2 +206,3 @@ return encoder.finish(); | ||
function doAbiDecode(schema, bytes) { | ||
var _a; | ||
const decoder = bytes instanceof Decoder ? bytes : new Decoder(bytes); | ||
@@ -302,3 +303,3 @@ if (typeof schema === 'string') { | ||
} | ||
else if (typeof schema === 'function') { | ||
else if (typeof ((_a = schema) === null || _a === void 0 ? void 0 : _a.abiDecode) === 'function') { | ||
return schema.abiDecode(decoder); | ||
@@ -305,0 +306,0 @@ } |
export { abiEncode, abiDecode, Schema, AbiEncodable, AbiDecodable, Encoder, Decoder, } from './abi'; | ||
export { Address, Balance } from './types'; | ||
export * from './gateway'; | ||
export { Address, Balance, ExecutionError } from './types'; | ||
export { encodeHex, decodeHex } from './utils'; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -8,5 +11,7 @@ var abi_1 = require("./abi"); | ||
exports.Decoder = abi_1.Decoder; | ||
__export(require("./gateway")); | ||
var types_1 = require("./types"); | ||
exports.Address = types_1.Address; | ||
exports.Balance = types_1.Balance; | ||
exports.ExecutionError = types_1.ExecutionError; | ||
var utils_1 = require("./utils"); | ||
@@ -13,0 +18,0 @@ exports.encodeHex = utils_1.encodeHex; |
@@ -38,2 +38,6 @@ import { AbiEncodable, Encoder, Decoder } from './abi'; | ||
} | ||
export declare class ExecutionError { | ||
output: Uint8Array; | ||
constructor(output: Uint8Array); | ||
} | ||
export {}; |
@@ -116,2 +116,8 @@ "use strict"; | ||
Balance.LENGTH = 16; // 128 bits | ||
class ExecutionError { | ||
constructor(output) { | ||
this.output = output; | ||
} | ||
} | ||
exports.ExecutionError = ExecutionError; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "oasis-std", | ||
"version": "0.1.0-rc.3", | ||
"version": "0.1.0-rc.4", | ||
"description": "Oasis platform standard library", | ||
@@ -14,5 +14,11 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"buffer": "^5.4.3" | ||
"@oasislabs/common": "^1.0.0-rc.15", | ||
"@oasislabs/confidential": "^1.0.0-rc.16", | ||
"@oasislabs/gateway": "^1.0.0-rc.27", | ||
"@oasislabs/service": "^1.0.0-rc.23", | ||
"buffer": "^5.4.3", | ||
"eventemitter3": "^4.0.0", | ||
"js-sha3": "^0.8.0" | ||
}, | ||
"gitHead": "943299d78a2a0ae3f2dabea1025fe19d1d606cc4" | ||
"gitHead": "01716c4b10578cfa4db39ee6d80df60abe0ca60a" | ||
} |
@@ -315,3 +315,3 @@ import { Buffer } from 'buffer'; | ||
return (schema as Schema[]).map(s => doAbiDecode(s, decoder)); | ||
} else if (typeof schema === 'function') { | ||
} else if (typeof (schema as any)?.abiDecode === 'function') { | ||
return (schema as AbiDecodable).abiDecode(decoder); | ||
@@ -318,0 +318,0 @@ } else { |
@@ -10,3 +10,4 @@ export { | ||
} from './abi'; | ||
export { Address, Balance } from './types'; | ||
export * from './gateway'; | ||
export { Address, Balance, ExecutionError } from './types'; | ||
export { encodeHex, decodeHex } from './utils'; |
@@ -140,1 +140,5 @@ import { decodeHex, encodeHex } from './utils'; | ||
} | ||
export class ExecutionError { | ||
public constructor(public output: Uint8Array) {} | ||
} |
import { abiEncode, abiDecode, Schema, Encoder } from '../src/abi'; | ||
import { typedArrayToBuffer, TypedArray } from '../src/utils'; | ||
import { typedArrayToBuffer } from '../src/utils'; | ||
import { randFill, randNumber, typedArrayLetter } from './utils'; | ||
describe('abiEncode', () => { | ||
@@ -430,37 +432,1 @@ it('void', () => { | ||
}); | ||
function randNumber(bits: number, ty: 'i' | 'u' | 'f'): number | bigint { | ||
const signed = ty !== 'u'; | ||
const sign = signed ? Number(Math.random() > 0.5) : 1; | ||
if (bits === 64 && ty !== 'f') { | ||
let maxValue = BigInt(18446744073709551616); // 2^64 | ||
if (signed) { | ||
maxValue = maxValue / BigInt(2) - BigInt(1); | ||
} | ||
return ( | ||
(maxValue / | ||
BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))) * | ||
BigInt(sign) | ||
); | ||
} else if (ty === 'f') { | ||
const largeValue = Math.pow(2, bits / 2); | ||
return Math.floor(largeValue * Math.random() * sign); | ||
} else { | ||
const maxValue = Math.pow(2, bits - Number(signed)); | ||
return Math.floor(maxValue * Math.random() * sign); | ||
} | ||
} | ||
function randFill(typedArray: TypedArray) { | ||
for (let i = 0; i < typedArray.length; i++) { | ||
typedArray[i] = randNumber( | ||
typedArray.BYTES_PER_ELEMENT * 8, | ||
typedArrayLetter(typedArray), | ||
); | ||
} | ||
} | ||
function typedArrayLetter(typedArray: TypedArray): 'u' | 'i' | 'f' { | ||
const name = typedArray.constructor.name; | ||
return name.startsWith('Float') ? 'f' : /Int/.test(name) ? 'i' : 'u'; | ||
} |
@@ -27,3 +27,3 @@ import { Buffer } from 'buffer'; | ||
it(`decode odd length`, () => { | ||
it('decode odd length', () => { | ||
expect(decodeHex('123456789abcdef')).toEqual( | ||
@@ -30,0 +30,0 @@ new Uint8Array([1, 35, 69, 103, 137, 171, 205, 239]), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 71 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116595751
354
3034
7
71
+ Addedeventemitter3@^4.0.0
+ Addedjs-sha3@^0.8.0
+ Added@hapi/bourne@2.1.0(transitive)
+ Added@oasislabs/common@1.0.0(transitive)
+ Added@oasislabs/confidential@1.0.0(transitive)
+ Added@oasislabs/gateway@1.0.0(transitive)
+ Added@oasislabs/service@1.0.0(transitive)
+ Added@types/node@22.10.1(transitive)
+ Added@types/pako@1.0.7(transitive)
+ Added@types/pino@6.3.12(transitive)
+ Added@types/pino-pretty@5.0.0(transitive)
+ Added@types/pino-std-serializers@4.0.0(transitive)
+ Added@types/uuid@3.4.13(transitive)
+ Addedansi-styles@3.2.14.3.0(transitive)
+ Addedargs@5.0.3(transitive)
+ Addedatomic-sleep@1.0.0(transitive)
+ Addedaxios@0.19.2(transitive)
+ Addedbsaes@0.0.2(transitive)
+ Addedcamelcase@5.0.05.3.1(transitive)
+ Addedcamelcase-keys@6.2.2(transitive)
+ Addedcbor-js@0.1.0(transitive)
+ Addedchalk@2.4.24.1.2(transitive)
+ Addedcolor-convert@1.9.32.0.1(transitive)
+ Addedcolor-name@1.1.31.1.4(transitive)
+ Addeddateformat@4.6.3(transitive)
+ Addeddeoxysii@0.0.2(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedeventemitter3@4.0.7(transitive)
+ Addedfast-redact@3.5.0(transitive)
+ Addedfast-safe-stringify@2.1.1(transitive)
+ Addedflatstr@1.0.12(transitive)
+ Addedfollow-redirects@1.5.10(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@3.0.04.0.0(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjmespath@0.15.0(transitive)
+ Addedjoycon@2.2.5(transitive)
+ Addedjs-sha3@0.8.0(transitive)
+ Addedjs-sha512@0.8.0(transitive)
+ Addedleven@2.1.0(transitive)
+ Addedmap-obj@4.3.0(transitive)
+ Addedmri@1.1.4(transitive)
+ Addednode-localstorage@2.2.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpako@1.0.11(transitive)
+ Addedpino@6.14.0(transitive)
+ Addedpino-pretty@4.8.0(transitive)
+ Addedpino-std-serializers@3.2.07.0.0(transitive)
+ Addedprocess-warning@1.0.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedquick-format-unescaped@4.0.4(transitive)
+ Addedquick-lru@4.0.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedrfdc@1.4.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedslide@1.1.6(transitive)
+ Addedsonic-boom@1.4.12.8.0(transitive)
+ Addedsplit2@3.2.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@5.5.07.2.0(transitive)
+ Addedtweetnacl@1.0.3(transitive)
+ Addeduint32@0.2.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedwrite-file-atomic@1.3.4(transitive)