refactor: move brother_node development artifact to dev/test-nodes subdirectory
Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
This commit is contained in:
2
dev/env/node_modules/micro-eth-signer/esm/_type_test.d.ts
generated
vendored
Executable file
2
dev/env/node_modules/micro-eth-signer/esm/_type_test.d.ts
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export type Bytes = Uint8Array;
|
||||
//# sourceMappingURL=_type_test.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/_type_test.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/_type_test.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"_type_test.d.ts","sourceRoot":"","sources":["../src/_type_test.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC"}
|
||||
230
dev/env/node_modules/micro-eth-signer/esm/_type_test.js
generated
vendored
Executable file
230
dev/env/node_modules/micro-eth-signer/esm/_type_test.js
generated
vendored
Executable file
@@ -0,0 +1,230 @@
|
||||
import * as P from 'micro-packed';
|
||||
import * as abi from "./abi/decoder.js";
|
||||
import * as typed from "./typed-data.js";
|
||||
// Should not be included in npm package, just for test of typescript compilation
|
||||
const assertType = (_value) => { };
|
||||
const BytesVal = new Uint8Array();
|
||||
const BigIntVal = BigInt(0);
|
||||
const StringVal = 'string';
|
||||
StringVal;
|
||||
const _a = Uint8Array.from([]);
|
||||
_a;
|
||||
// IsEmptyArray
|
||||
const isEmpty = (a) => a;
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([1]));
|
||||
assertType(isEmpty(['a', 2]));
|
||||
assertType(isEmpty(['a']));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty([]));
|
||||
assertType(isEmpty(undefined));
|
||||
const t = [
|
||||
{
|
||||
type: 'constructor',
|
||||
inputs: [{ name: 'a', type: 'uint256' }],
|
||||
stateMutability: 'nonpayable',
|
||||
},
|
||||
];
|
||||
assertType(isEmpty(t));
|
||||
// Tests
|
||||
assertType(abi.mapComponent({ type: 'string' }));
|
||||
assertType(abi.mapComponent({ type: 'string[]' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes[]' }));
|
||||
assertType(abi.mapComponent({ type: 'address' }));
|
||||
assertType(abi.mapComponent({ type: 'address[]' }));
|
||||
assertType(abi.mapComponent({ type: 'bool' }));
|
||||
assertType(abi.mapComponent({ type: 'bool[]' }));
|
||||
assertType(abi.mapComponent({ type: 'uint16' }));
|
||||
assertType(abi.mapComponent({ type: 'uint16[]' }));
|
||||
assertType(abi.mapComponent({ type: 'int' }));
|
||||
assertType(abi.mapComponent({ type: 'int[]' }));
|
||||
assertType(abi.mapComponent({ type: 'int24' }));
|
||||
assertType(abi.mapComponent({ type: 'int24[]' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes1' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes1[]' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes15' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes15[]' }));
|
||||
// Tuples
|
||||
assertType(abi.mapComponent({
|
||||
type: 'tuple',
|
||||
components: [
|
||||
{ type: 'uint16', name: 'lol' },
|
||||
{ type: 'string', name: 'wut' },
|
||||
],
|
||||
}));
|
||||
assertType(abi.mapComponent({
|
||||
type: 'tuple',
|
||||
components: [{ type: 'uint16', name: 'lol' }, { type: 'string' }],
|
||||
}));
|
||||
//
|
||||
assertType(abi.mapComponent({ type: 'tuple' }));
|
||||
assertType(abi.mapComponent({ type: 'int25' }));
|
||||
assertType(abi.mapComponent({ type: 'bytes0' }));
|
||||
// Args
|
||||
// If single arg -- use as is
|
||||
assertType(BytesVal);
|
||||
// no names -> tuple
|
||||
assertType([BytesVal, BigIntVal]);
|
||||
// has names -> struct
|
||||
assertType({
|
||||
lol: BytesVal,
|
||||
wut: BigIntVal,
|
||||
});
|
||||
// WHY?!
|
||||
assertType(abi.mapArgs([{ type: 'string' }]));
|
||||
assertType(abi.mapArgs([{ type: 'bytes1' }]));
|
||||
assertType(abi.mapArgs([{ type: 'string' }, { type: 'uint' }]));
|
||||
assertType(abi.mapArgs([
|
||||
{ type: 'string', name: 'lol' },
|
||||
{ type: 'uint', name: 'wut' },
|
||||
]));
|
||||
// Without const
|
||||
assertType(abi.mapArgs([
|
||||
{ type: 'string', name: 'lol' },
|
||||
{ type: 'uint', name: 'wut' },
|
||||
]));
|
||||
assertType(abi.mapArgs([{ type: 'string' }, { type: 'uint' }]));
|
||||
// unfortunately, typescript cannot detect single value arr on non-const data
|
||||
assertType(abi.mapArgs([{ type: 'bytes1' }]));
|
||||
assertType(abi.createContract([
|
||||
{
|
||||
name: 'lol',
|
||||
type: 'function',
|
||||
inputs: [{ type: 'uint' }, { type: 'string' }],
|
||||
outputs: [{ type: 'bytes' }, { type: 'address' }],
|
||||
},
|
||||
]));
|
||||
assertType(abi.createContract([
|
||||
{
|
||||
name: 'lol',
|
||||
type: 'function',
|
||||
outputs: [{ type: 'bytes' }, { type: 'address' }],
|
||||
},
|
||||
]));
|
||||
assertType(abi.createContract([
|
||||
{
|
||||
name: 'lol',
|
||||
type: 'function',
|
||||
inputs: [],
|
||||
outputs: [{ type: 'bytes' }, { type: 'address' }],
|
||||
},
|
||||
]));
|
||||
assertType(abi.createContract([
|
||||
{
|
||||
name: 'lol',
|
||||
type: 'function',
|
||||
inputs: [{ type: 'uint' }, { type: 'string' }],
|
||||
outputs: [{ type: 'bytes' }, { type: 'address' }],
|
||||
},
|
||||
], 1));
|
||||
// Without const there is not much can be derived from abi
|
||||
assertType(abi.createContract([
|
||||
{
|
||||
name: 'lol',
|
||||
type: 'function',
|
||||
inputs: [{ type: 'uint' }, { type: 'string' }],
|
||||
outputs: [{ type: 'bytes' }, { type: 'address' }],
|
||||
},
|
||||
]));
|
||||
const PAIR_CONTRACT = [
|
||||
{
|
||||
type: 'function',
|
||||
name: 'getReserves',
|
||||
outputs: [
|
||||
{ name: 'reserve0', type: 'uint112' },
|
||||
{ name: 'reserve1', type: 'uint112' },
|
||||
{ name: 'blockTimestampLast', type: 'uint32' },
|
||||
],
|
||||
},
|
||||
];
|
||||
assertType(abi.createContract(PAIR_CONTRACT));
|
||||
const TRANSFER_EVENT = [
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{ indexed: true, name: 'from', type: 'address' },
|
||||
{ indexed: true, name: 'to', type: 'address' },
|
||||
{ indexed: false, name: 'value', type: 'uint256' },
|
||||
],
|
||||
name: 'Transfer',
|
||||
type: 'event',
|
||||
},
|
||||
];
|
||||
assertType(abi.events(TRANSFER_EVENT));
|
||||
// Typed data
|
||||
const types = {
|
||||
Person: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'wallet', type: 'address' },
|
||||
],
|
||||
Mail: [
|
||||
{ name: 'from', type: 'Person' },
|
||||
{ name: 'to', type: 'Person' },
|
||||
{ name: 'contents', type: 'string' },
|
||||
],
|
||||
Group: [
|
||||
{ name: 'members', type: 'Person[]' },
|
||||
{ name: 'owner', type: 'Person' },
|
||||
],
|
||||
Complex0: [
|
||||
{ name: 'data', type: 'string[][]' }, // Complex array type
|
||||
{ name: 'info', type: 'Mail' },
|
||||
],
|
||||
Complex1: [
|
||||
{ name: 'data', type: 'string[][][]' }, // Complex array type
|
||||
{ name: 'info', type: 'Mail' },
|
||||
],
|
||||
Complex: [
|
||||
{ name: 'data', type: 'string[][3][]' }, // Complex array type
|
||||
{ name: 'info', type: 'Mail' },
|
||||
],
|
||||
};
|
||||
assertType(1);
|
||||
assertType(1);
|
||||
assertType(1);
|
||||
assertType(1);
|
||||
assertType(1);
|
||||
assertType(1);
|
||||
const recursiveTypes = {
|
||||
Node: [
|
||||
{ name: 'value', type: 'string' },
|
||||
{ name: 'children', type: 'Node[]' },
|
||||
],
|
||||
};
|
||||
assertType(1);
|
||||
// const e = typed.encoder(types);
|
||||
// e.encodeData('Person', { name: 'test', wallet: 'x' });
|
||||
// e.sign({ primaryType: 'Person', message: { name: 'test', wallet: 'x' }, domain: {} }, '');
|
||||
// e.encodeData('Person', { name: 'test', wallet: 1n }); // should fail
|
||||
// e.sign({ primaryType: 'Person', message: {name: 'test'}, domain: {} }, ''); // should fail
|
||||
// e.sign({ primaryType: 'Person', message: {name: 'test', wallet: '', s: 3}, domain: {} }, ''); // should fail
|
||||
// constructor
|
||||
abi.deployContract([{ type: 'constructor', inputs: [], stateMutability: 'nonpayable' }], '0x00');
|
||||
abi.deployContract([{ type: 'constructor', stateMutability: 'nonpayable' }], '0x00');
|
||||
// abi.deployContract(
|
||||
// [{ type: 'constructor', stateMutability: 'nonpayable' }] as const,
|
||||
// '0x00',
|
||||
// undefined
|
||||
// ); // should fail!
|
||||
abi.deployContract([{ type: 'constructor', stateMutability: 'nonpayable' }], '0x00', undefined); // if we cannot infer type - it will be 'unknown' (and user forced to provide any argument, undefined is ok)
|
||||
abi.deployContract([
|
||||
{
|
||||
type: 'constructor',
|
||||
inputs: [{ name: 'a', type: 'uint256' }],
|
||||
stateMutability: 'nonpayable',
|
||||
},
|
||||
], '0x00', BigInt(100));
|
||||
abi.deployContract([
|
||||
{
|
||||
type: 'constructor',
|
||||
inputs: [{ name: 'a', type: 'uint256' }],
|
||||
stateMutability: 'nonpayable',
|
||||
},
|
||||
], '0x00', BigInt(100));
|
||||
//# sourceMappingURL=_type_test.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/_type_test.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/_type_test.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
5
dev/env/node_modules/micro-eth-signer/esm/abi/common.d.ts
generated
vendored
Executable file
5
dev/env/node_modules/micro-eth-signer/esm/abi/common.d.ts
generated
vendored
Executable file
@@ -0,0 +1,5 @@
|
||||
import type { ContractABI, HintFn, HookFn } from './decoder.ts';
|
||||
export declare function addHint<T extends ContractABI>(abi: ContractABI, name: string, fn: HintFn): T;
|
||||
export declare function addHints<T extends ContractABI>(abi: T, map: Record<string, HintFn>): T;
|
||||
export declare function addHook<T extends ContractABI>(abi: T, name: string, fn: HookFn): T;
|
||||
//# sourceMappingURL=common.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/common.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/common.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/abi/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEhE,wBAAgB,OAAO,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAO5F;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAQtF;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAOlF"}
|
||||
32
dev/env/node_modules/micro-eth-signer/esm/abi/common.js
generated
vendored
Executable file
32
dev/env/node_modules/micro-eth-signer/esm/abi/common.js
generated
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
export function addHint(abi, name, fn) {
|
||||
const res = [];
|
||||
for (const elm of abi) {
|
||||
if (elm.name === name)
|
||||
res.push({ ...elm, hint: fn });
|
||||
else
|
||||
res.push(elm);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
export function addHints(abi, map) {
|
||||
const res = [];
|
||||
for (const elm of abi) {
|
||||
if (['event', 'function'].includes(elm.type) && elm.name && map[elm.name]) {
|
||||
res.push({ ...elm, hint: map[elm.name] });
|
||||
}
|
||||
else
|
||||
res.push(elm);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
export function addHook(abi, name, fn) {
|
||||
const res = [];
|
||||
for (const elm of abi) {
|
||||
if (elm.type === 'function' && elm.name === name)
|
||||
res.push({ ...elm, hook: fn });
|
||||
else
|
||||
res.push(elm);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//# sourceMappingURL=common.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/common.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/common.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/abi/common.ts"],"names":[],"mappings":"AAEA,MAAM,UA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CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,GAAmB,CAAC;AAC7B,CAAC"}
|
||||
167
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.d.ts
generated
vendored
Executable file
167
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.d.ts
generated
vendored
Executable file
@@ -0,0 +1,167 @@
|
||||
import * as P from 'micro-packed';
|
||||
import { type IWeb3Provider } from '../utils.ts';
|
||||
type Writable<T> = T extends {} ? {
|
||||
-readonly [P in keyof T]: Writable<T[P]>;
|
||||
} : T;
|
||||
type ArrLike<T> = Array<T> | ReadonlyArray<T>;
|
||||
export type IsEmptyArray<T> = T extends ReadonlyArray<any> ? (T['length'] extends 0 ? true : false) : true;
|
||||
export type Component<T extends string> = {
|
||||
readonly name?: string;
|
||||
readonly type: T;
|
||||
};
|
||||
export type NamedComponent<T extends string> = Component<T> & {
|
||||
readonly name: string;
|
||||
};
|
||||
export type BaseComponent = Component<string>;
|
||||
export type Tuple<TC extends ArrLike<Component<string>>> = {
|
||||
readonly name?: string;
|
||||
readonly type: 'tuple';
|
||||
readonly components: TC;
|
||||
};
|
||||
type IntIdxType = '' | '8' | '16' | '24' | '32' | '40' | '48' | '56' | '64' | '72' | '80' | '88' | '96' | '104' | '112' | '120' | '128' | '136' | '144' | '152' | '160' | '168' | '176' | '184' | '192' | '200' | '208' | '216' | '224' | '232' | '240' | '248' | '256';
|
||||
type UintType = `uint${IntIdxType}`;
|
||||
type IntType = `int${IntIdxType}`;
|
||||
type NumberType = UintType | IntType;
|
||||
type ByteIdxType = '' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17' | '18' | '19' | '20' | '21' | '22' | '23' | '24' | '25' | '26' | '27' | '28' | '29' | '30' | '31' | '32';
|
||||
type ByteType = `bytes${ByteIdxType}`;
|
||||
export type MapTuple<T> = T extends ArrLike<Component<string> & {
|
||||
name: string;
|
||||
}> ? {
|
||||
[K in T[number] as K['name']]: MapType<K>;
|
||||
} : T extends ArrLike<Component<string>> ? {
|
||||
[K in keyof T]: T[K] extends BaseComponent ? MapType<T[K]> : unknown;
|
||||
} : unknown;
|
||||
export type GetType<T extends string> = T extends `${infer Base}[]${infer Rest}` ? GetType<`${Base}${Rest}`>[] : T extends `${infer Base}[${number}]${infer Rest}` ? GetType<`${Base}${Rest}`>[] : T extends 'address' ? string : T extends 'string' ? string : T extends 'bool' ? boolean : T extends NumberType ? bigint : T extends ByteType ? Uint8Array : unknown;
|
||||
export type MapType<T extends BaseComponent> = T extends Tuple<Array<Component<string>>> ? MapTuple<T['components']> : T extends Component<infer Type> ? GetType<Type> : unknown;
|
||||
export type UnmapType<T> = T extends MapType<infer U> ? U : never;
|
||||
export declare function mapComponent<T extends BaseComponent>(c: T): P.CoderType<MapType<Writable<T>>>;
|
||||
export type ArgsType<T extends ReadonlyArray<any> | undefined> = IsEmptyArray<T> extends true ? undefined : T extends ReadonlyArray<any> ? T['length'] extends 1 ? MapType<T[0]> : MapTuple<T> : MapTuple<T>;
|
||||
export declare function mapArgs<T extends ArrLike<Component<string>>>(args: T): P.CoderType<ArgsType<Writable<T>>>;
|
||||
export type FunctionType = Component<'function'> & {
|
||||
readonly inputs?: ReadonlyArray<Component<string>>;
|
||||
readonly outputs?: ReadonlyArray<Component<string>>;
|
||||
};
|
||||
type ContractMethodDecode<T extends FunctionType, O = ArgsType<T['outputs']>> = IsEmptyArray<T['outputs']> extends true ? {
|
||||
decodeOutput: (b: Uint8Array) => void;
|
||||
} : {
|
||||
decodeOutput: (b: Uint8Array) => O;
|
||||
};
|
||||
type ContractMethodEncode<T extends FunctionType, I = ArgsType<T['inputs']>> = IsEmptyArray<T['inputs']> extends true ? {
|
||||
encodeInput: () => Uint8Array;
|
||||
} : {
|
||||
encodeInput: (v: I) => Uint8Array;
|
||||
};
|
||||
type ContractMethodGas<T extends FunctionType, I = ArgsType<T['inputs']>> = IsEmptyArray<T['inputs']> extends true ? {
|
||||
estimateGas: () => Promise<bigint>;
|
||||
} : {
|
||||
estimateGas: (v: I) => Promise<bigint>;
|
||||
};
|
||||
type ContractMethodCall<T extends FunctionType, I = ArgsType<T['inputs']>, O = ArgsType<T['outputs']>> = IsEmptyArray<T['inputs']> extends true ? IsEmptyArray<T['outputs']> extends true ? {
|
||||
call: () => Promise<void>;
|
||||
} : {
|
||||
call: () => Promise<O>;
|
||||
} : IsEmptyArray<T['outputs']> extends true ? {
|
||||
call: (v: I) => Promise<void>;
|
||||
} : {
|
||||
call: (v: I) => Promise<O>;
|
||||
};
|
||||
export type ContractMethod<T extends FunctionType> = ContractMethodEncode<T> & ContractMethodDecode<T>;
|
||||
export type ContractMethodNet<T extends FunctionType> = ContractMethod<T> & ContractMethodGas<T> & ContractMethodCall<T>;
|
||||
export type FnArg = {
|
||||
readonly type: string;
|
||||
readonly name?: string;
|
||||
readonly components?: ArrLike<FnArg>;
|
||||
readonly inputs?: ArrLike<FnArg>;
|
||||
readonly outputs?: ArrLike<FnArg>;
|
||||
readonly anonymous?: boolean;
|
||||
readonly indexed?: boolean;
|
||||
};
|
||||
export type ContractTypeFilter<T> = {
|
||||
[K in keyof T]: T[K] extends FunctionType & {
|
||||
name: string;
|
||||
} ? T[K] : never;
|
||||
};
|
||||
export type ContractType<T extends Array<FnArg>, N, F = ContractTypeFilter<T>> = F extends ArrLike<FunctionType & {
|
||||
name: string;
|
||||
}> ? {
|
||||
[K in F[number] as K['name']]: N extends IWeb3Provider ? ContractMethodNet<K> : ContractMethod<K>;
|
||||
} : never;
|
||||
export declare function evSigHash(o: FnArg): string;
|
||||
export declare function fnSigHash(o: FnArg): string;
|
||||
export declare function createContract<T extends ArrLike<FnArg>>(abi: T, net: IWeb3Provider, contract?: string): ContractType<Writable<T>, IWeb3Provider>;
|
||||
export declare function createContract<T extends ArrLike<FnArg>>(abi: T, net?: undefined, contract?: string): ContractType<Writable<T>, undefined>;
|
||||
type GetCons<T extends ArrLike<FnArg>> = Extract<T[number], {
|
||||
type: 'constructor';
|
||||
}>;
|
||||
type ConstructorType = Component<'constructor'> & {
|
||||
readonly inputs?: ReadonlyArray<Component<string>>;
|
||||
};
|
||||
type ConsArgs<T extends ConstructorType> = IsEmptyArray<T['inputs']> extends true ? undefined : ArgsType<T['inputs']>;
|
||||
export declare function deployContract<T extends ArrLike<FnArg>>(abi: T, bytecodeHex: string, ...args: GetCons<T> extends never ? [args: unknown] : ConsArgs<GetCons<T>> extends undefined ? [] : [args: ConsArgs<GetCons<T>>]): string;
|
||||
export type EventType = NamedComponent<'event'> & {
|
||||
readonly inputs: ReadonlyArray<Component<string>>;
|
||||
};
|
||||
export type ContractEventTypeFilter<T> = {
|
||||
[K in keyof T]: T[K] extends EventType ? T[K] : never;
|
||||
};
|
||||
export type TopicsValue<T> = {
|
||||
[K in keyof T]: T[K] | null;
|
||||
};
|
||||
export type EventMethod<T extends EventType> = {
|
||||
decode: (topics: string[], data: string) => ArgsType<T['inputs']>;
|
||||
topics: (values: TopicsValue<ArgsType<T['inputs']>>) => (string | null)[];
|
||||
};
|
||||
export type ContractEventType<T extends Array<FnArg>, F = ContractEventTypeFilter<T>> = F extends ArrLike<EventType> ? {
|
||||
[K in F[number] as K['name']]: EventMethod<K>;
|
||||
} : never;
|
||||
export declare function events<T extends ArrLike<FnArg>>(abi: T): ContractEventType<Writable<T>>;
|
||||
export type ContractABI = ReadonlyArray<FnArg & {
|
||||
readonly hint?: HintFn;
|
||||
readonly hook?: HookFn;
|
||||
}>;
|
||||
export type ContractInfo = {
|
||||
abi: 'ERC20' | 'ERC721' | 'ERC1155' | ContractABI;
|
||||
symbol?: string;
|
||||
decimals?: number;
|
||||
name?: string;
|
||||
price?: number;
|
||||
};
|
||||
export type HintOpt = {
|
||||
contract?: string;
|
||||
amount?: bigint;
|
||||
contractInfo?: ContractInfo;
|
||||
contracts?: Record<string, ContractInfo>;
|
||||
};
|
||||
export type HintFn = (value: unknown, opt: HintOpt) => string;
|
||||
export type HookFn = (decoder: Decoder, contract: string, info: SignatureInfo, opt: HintOpt) => SignatureInfo;
|
||||
type SignaturePacker = {
|
||||
name: string;
|
||||
signature: string;
|
||||
packer: P.CoderType<unknown>;
|
||||
hint?: HintFn;
|
||||
hook?: HookFn;
|
||||
};
|
||||
type EventSignatureDecoder = {
|
||||
name: string;
|
||||
signature: string;
|
||||
decoder: (topics: string[], _data: string) => unknown;
|
||||
hint?: HintFn;
|
||||
};
|
||||
export type SignatureInfo = {
|
||||
name: string;
|
||||
signature: string;
|
||||
value: unknown;
|
||||
hint?: string;
|
||||
};
|
||||
export declare class Decoder {
|
||||
contracts: Record<string, Record<string, SignaturePacker>>;
|
||||
sighashes: Record<string, SignaturePacker[]>;
|
||||
evContracts: Record<string, Record<string, EventSignatureDecoder>>;
|
||||
evSighashes: Record<string, EventSignatureDecoder[]>;
|
||||
add(contract: string, abi: ContractABI): void;
|
||||
method(contract: string, data: Uint8Array): string | undefined;
|
||||
decode(contract: string, _data: Uint8Array, opt: HintOpt): SignatureInfo | SignatureInfo[] | undefined;
|
||||
decodeEvent(contract: string, topics: string[], data: string, opt: HintOpt): SignatureInfo | SignatureInfo[] | undefined;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=decoder.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.d.ts.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
436
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.js
generated
vendored
Executable file
436
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.js
generated
vendored
Executable file
@@ -0,0 +1,436 @@
|
||||
import { keccak_256 } from '@noble/hashes/sha3';
|
||||
import { bytesToHex, concatBytes, hexToBytes } from '@noble/hashes/utils';
|
||||
import * as P from 'micro-packed';
|
||||
import { add0x, ethHex, omit, strip0x, zip, } from "../utils.js";
|
||||
/*
|
||||
There is NO network code in the file. However, a user can pass
|
||||
NetProvider instance to createContract, and the method would do
|
||||
network requests with the api.
|
||||
|
||||
There is some really crazy stuff going on here with Typescript types.
|
||||
*/
|
||||
function EPad(p) {
|
||||
return P.padLeft(32, p, P.ZeroPad);
|
||||
}
|
||||
// Main difference between regular array: length stored outside and offsets calculated without length
|
||||
function ethArray(inner) {
|
||||
return P.wrap({
|
||||
size: undefined,
|
||||
encodeStream: (w, value) => {
|
||||
U256BE_LEN.encodeStream(w, value.length);
|
||||
w.bytes(P.array(value.length, inner).encode(value));
|
||||
},
|
||||
decodeStream: (r) => P.array(U256BE_LEN.decodeStream(r), inner).decodeStream(r.offsetReader(r.pos)),
|
||||
});
|
||||
}
|
||||
const PTR = EPad(P.U32BE);
|
||||
const ARRAY_RE = /(.+)(\[(\d+)?\])$/; // TODO: is this correct?
|
||||
// Because u32 in eth is not real u32, just U256BE with limits...
|
||||
const ethInt = (bits, signed = false) => {
|
||||
if (!Number.isSafeInteger(bits) || bits <= 0 || bits % 8 !== 0 || bits > 256)
|
||||
throw new Error('ethInt: invalid numeric type');
|
||||
const _bits = BigInt(bits);
|
||||
const inner = P.bigint(32, false, signed);
|
||||
return P.validate(P.wrap({
|
||||
size: inner.size,
|
||||
encodeStream: (w, value) => inner.encodeStream(w, value),
|
||||
decodeStream: (r) => inner.decodeStream(r),
|
||||
}), (value) => {
|
||||
// TODO: validate useful for narrowing types, need to add support in types?
|
||||
if (typeof value === 'number')
|
||||
value = BigInt(value);
|
||||
P.utils.checkBounds(value, _bits, !!signed);
|
||||
return value;
|
||||
});
|
||||
};
|
||||
// Ugly hack, because tuple of pointers considered "dynamic" without any reason.
|
||||
function isDyn(args) {
|
||||
let res = false;
|
||||
if (Array.isArray(args)) {
|
||||
for (let arg of args)
|
||||
if (arg.size === undefined)
|
||||
res = true;
|
||||
}
|
||||
else {
|
||||
for (let arg in args)
|
||||
if (args[arg].size === undefined)
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Re-use ptr for len. u32 should be enough.
|
||||
const U256BE_LEN = PTR;
|
||||
// NOTE: we need as const if we want to access string as values inside types :(
|
||||
export function mapComponent(c) {
|
||||
// Arrays (should be first one, since recursive)
|
||||
let m;
|
||||
if ((m = ARRAY_RE.exec(c.type))) {
|
||||
const inner = mapComponent({ ...c, type: m[1] });
|
||||
if (inner.size === 0)
|
||||
throw new Error('mapComponent: arrays of zero-size elements disabled (possible DoS attack)');
|
||||
// Static array
|
||||
if (m[3] !== undefined) {
|
||||
const m3 = Number.parseInt(m[3]);
|
||||
if (!Number.isSafeInteger(m3))
|
||||
throw new Error(`mapComponent: wrong array size=${m[3]}`);
|
||||
let out = P.array(m3, inner);
|
||||
// Static array of dynamic values should be behind pointer too, again without reason.
|
||||
if (inner.size === undefined)
|
||||
out = P.pointer(PTR, out);
|
||||
return out;
|
||||
}
|
||||
else {
|
||||
// Dynamic array
|
||||
return P.pointer(PTR, ethArray(inner));
|
||||
}
|
||||
}
|
||||
if (c.type === 'tuple') {
|
||||
const components = c.components;
|
||||
let hasNames = true;
|
||||
const args = [];
|
||||
for (let comp of components) {
|
||||
if (!comp.name)
|
||||
hasNames = false;
|
||||
args.push(mapComponent(comp));
|
||||
}
|
||||
let out;
|
||||
// If there is names for all fields -- return struct, otherwise tuple
|
||||
if (hasNames) {
|
||||
const struct = {};
|
||||
for (const arg of components) {
|
||||
if (struct[arg.name])
|
||||
throw new Error(`mapType: same field name=${arg.name}`);
|
||||
struct[arg.name] = mapComponent(arg);
|
||||
}
|
||||
out = P.struct(struct);
|
||||
}
|
||||
else
|
||||
out = P.tuple(args);
|
||||
// If tuple has dynamic elements it becomes dynamic too, without reason.
|
||||
if (isDyn(args))
|
||||
out = P.pointer(PTR, out);
|
||||
return out;
|
||||
}
|
||||
if (c.type === 'string')
|
||||
return P.pointer(PTR, P.padRight(32, P.string(U256BE_LEN), P.ZeroPad));
|
||||
if (c.type === 'bytes')
|
||||
return P.pointer(PTR, P.padRight(32, P.bytes(U256BE_LEN), P.ZeroPad));
|
||||
if (c.type === 'address')
|
||||
return EPad(P.hex(20, { isLE: false, with0x: true }));
|
||||
if (c.type === 'bool')
|
||||
return EPad(P.bool);
|
||||
if ((m = /^(u?)int([0-9]+)?$/.exec(c.type)))
|
||||
return ethInt(m[2] ? +m[2] : 256, m[1] !== 'u');
|
||||
if ((m = /^bytes([0-9]{1,2})$/.exec(c.type))) {
|
||||
const parsed = +m[1];
|
||||
if (!parsed || parsed > 32)
|
||||
throw new Error('wrong bytes<N> type');
|
||||
return P.padRight(32, P.bytes(parsed), P.ZeroPad);
|
||||
}
|
||||
throw new Error(`mapComponent: unknown component=${c}`);
|
||||
}
|
||||
// Because args and output are not tuple
|
||||
// TODO: try merge with mapComponent
|
||||
export function mapArgs(args) {
|
||||
// More ergonomic input/output
|
||||
if (args.length === 1)
|
||||
return mapComponent(args[0]);
|
||||
let hasNames = true;
|
||||
for (const arg of args)
|
||||
if (!arg.name)
|
||||
hasNames = false;
|
||||
if (hasNames) {
|
||||
const out = {};
|
||||
for (const arg of args) {
|
||||
const name = arg.name;
|
||||
if (out[name])
|
||||
throw new Error(`mapArgs: same field name=${name}`);
|
||||
out[name] = mapComponent(arg);
|
||||
}
|
||||
return P.struct(out);
|
||||
}
|
||||
else
|
||||
return P.tuple(args.map(mapComponent));
|
||||
}
|
||||
function fnSignature(o) {
|
||||
if (!o.type)
|
||||
throw new Error('ABI.fnSignature wrong argument');
|
||||
if (o.type === 'function' || o.type === 'event')
|
||||
return `${o.name || 'function'}(${(o.inputs || []).map((i) => fnSignature(i)).join(',')})`;
|
||||
if (o.type.startsWith('tuple')) {
|
||||
if (!o.components || !o.components.length)
|
||||
throw new Error('ABI.fnSignature wrong tuple');
|
||||
return `(${o.components.map((i) => fnSignature(i)).join(',')})${o.type.slice(5)}`;
|
||||
}
|
||||
return o.type;
|
||||
}
|
||||
// Function signature hash
|
||||
export function evSigHash(o) {
|
||||
return bytesToHex(keccak_256(fnSignature(o)));
|
||||
}
|
||||
export function fnSigHash(o) {
|
||||
return evSigHash(o).slice(0, 8);
|
||||
}
|
||||
export function createContract(abi, net, contract) {
|
||||
// Find non-uniq function names so we can handle overloads
|
||||
let nameCnt = {};
|
||||
for (let fn of abi) {
|
||||
if (fn.type !== 'function')
|
||||
continue;
|
||||
const name = fn.name || 'function';
|
||||
if (!nameCnt[name])
|
||||
nameCnt[name] = 1;
|
||||
else
|
||||
nameCnt[name]++;
|
||||
}
|
||||
const res = {};
|
||||
for (let fn of abi) {
|
||||
if (fn.type !== 'function')
|
||||
continue;
|
||||
let name = fn.name || 'function';
|
||||
if (nameCnt[name] > 1)
|
||||
name = fnSignature(fn);
|
||||
const sh = fnSigHash(fn);
|
||||
const inputs = fn.inputs && fn.inputs.length ? mapArgs(fn.inputs) : undefined;
|
||||
const outputs = fn.outputs ? mapArgs(fn.outputs) : undefined;
|
||||
const decodeOutput = (b) => outputs && outputs.decode(b);
|
||||
const encodeInput = (v) => concatBytes(hexToBytes(sh), inputs ? inputs.encode(v) : new Uint8Array());
|
||||
res[name] = { decodeOutput, encodeInput };
|
||||
// .call and .estimateGas call network, when net is available
|
||||
if (!net)
|
||||
continue;
|
||||
res[name].call = async (args, overrides = {}) => {
|
||||
if (!contract && !overrides.to)
|
||||
throw new Error('No contract address');
|
||||
const data = add0x(bytesToHex(encodeInput(args)));
|
||||
const callArgs = Object.assign({ to: contract, data }, overrides);
|
||||
return decodeOutput(hexToBytes(strip0x(await net.ethCall(callArgs))));
|
||||
};
|
||||
res[name].estimateGas = async (args, overrides = {}) => {
|
||||
if (!contract && !overrides.to)
|
||||
throw new Error('No contract address');
|
||||
const data = add0x(bytesToHex(encodeInput(args)));
|
||||
const callArgs = Object.assign({ to: contract, data }, overrides);
|
||||
return await net.estimateGas(callArgs);
|
||||
};
|
||||
}
|
||||
return res;
|
||||
}
|
||||
export function deployContract(abi, bytecodeHex, ...args) {
|
||||
const bytecode = ethHex.decode(bytecodeHex);
|
||||
let consCall;
|
||||
for (let fn of abi) {
|
||||
if (fn.type !== 'constructor')
|
||||
continue;
|
||||
const inputs = fn.inputs && fn.inputs.length ? mapArgs(fn.inputs) : undefined;
|
||||
if (inputs === undefined && args !== undefined && args.length)
|
||||
throw new Error('arguments to constructor without any');
|
||||
consCall = inputs ? inputs.encode(args[0]) : new Uint8Array();
|
||||
}
|
||||
if (!consCall)
|
||||
throw new Error('constructor not found');
|
||||
return ethHex.encode(concatBytes(bytecode, consCall));
|
||||
}
|
||||
// TODO: try to simplify further
|
||||
export function events(abi) {
|
||||
let res = {};
|
||||
for (let elm of abi) {
|
||||
// Only named events supported
|
||||
if (elm.type !== 'event' || !elm.name)
|
||||
continue;
|
||||
const inputs = elm.inputs || [];
|
||||
let hasNames = true;
|
||||
for (let i of inputs)
|
||||
if (!i.name)
|
||||
hasNames = false;
|
||||
const plainInp = inputs.filter((i) => !i.indexed);
|
||||
const indexedInp = inputs.filter((i) => i.indexed);
|
||||
const indexed = indexedInp.map((i) => !['string', 'bytes', 'tuple'].includes(i.type) && !ARRAY_RE.exec(i.type)
|
||||
? mapArgs([i])
|
||||
: null);
|
||||
const parser = mapArgs(hasNames ? plainInp : plainInp.map((i) => omit(i, 'name')));
|
||||
const sigHash = evSigHash(elm);
|
||||
res[elm.name] = {
|
||||
decode(topics, _data) {
|
||||
const data = hexToBytes(strip0x(_data));
|
||||
if (!elm.anonymous) {
|
||||
if (!topics[0])
|
||||
throw new Error('No signature on non-anonymous event');
|
||||
if (strip0x(topics[0]).toLowerCase() !== sigHash)
|
||||
throw new Error('Wrong signature');
|
||||
topics = topics.slice(1);
|
||||
}
|
||||
if (topics.length !== indexed.length)
|
||||
throw new Error('Wrong topics length');
|
||||
let parsed = parser ? parser.decode(data) : hasNames ? {} : [];
|
||||
const indexedParsed = indexed.map((p, i) => p ? p.decode(hexToBytes(strip0x(topics[i]))) : topics[i]);
|
||||
if (plainInp.length === 1)
|
||||
parsed = hasNames ? { [plainInp[0].name]: parsed } : [parsed];
|
||||
if (hasNames) {
|
||||
let res = { ...parsed };
|
||||
for (let [a, p] of zip(indexedInp, indexedParsed))
|
||||
res[a.name] = p;
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return inputs.map((i) => (!i.indexed ? parsed : indexedParsed).shift());
|
||||
},
|
||||
topics(values) {
|
||||
let res = [];
|
||||
if (!elm.anonymous)
|
||||
res.push(add0x(sigHash));
|
||||
// We require all keys to be set, even if they are null, to be sure nothing is accidentaly missed
|
||||
if ((hasNames ? Object.keys(values) : values).length !== inputs.length)
|
||||
throw new Error('Wrong topics args');
|
||||
for (let i = 0, ii = 0; i < inputs.length && ii < indexed.length; i++) {
|
||||
const [input, packer] = [inputs[i], indexed[ii]];
|
||||
if (!input.indexed)
|
||||
continue;
|
||||
const value = values[Array.isArray(values) ? i : inputs[i].name];
|
||||
if (value === null) {
|
||||
res.push(null);
|
||||
continue;
|
||||
}
|
||||
let topic;
|
||||
if (packer)
|
||||
topic = bytesToHex(packer.encode(value));
|
||||
else if (['string', 'bytes'].includes(input.type))
|
||||
topic = bytesToHex(keccak_256(value));
|
||||
else {
|
||||
let m, parts;
|
||||
if ((m = ARRAY_RE.exec(input.type)))
|
||||
parts = value.map((j) => mapComponent({ type: m[1] }).encode(j));
|
||||
else if (input.type === 'tuple' && input.components)
|
||||
parts = input.components.map((j) => mapArgs([j]).encode(value[j.name]));
|
||||
else
|
||||
throw new Error('Unknown unsized type');
|
||||
topic = bytesToHex(keccak_256(concatBytes(...parts)));
|
||||
}
|
||||
res.push(add0x(topic));
|
||||
ii++;
|
||||
}
|
||||
return res;
|
||||
},
|
||||
};
|
||||
}
|
||||
return res;
|
||||
}
|
||||
export class Decoder {
|
||||
constructor() {
|
||||
this.contracts = {};
|
||||
this.sighashes = {};
|
||||
this.evContracts = {};
|
||||
this.evSighashes = {};
|
||||
}
|
||||
add(contract, abi) {
|
||||
const ev = events(abi);
|
||||
contract = strip0x(contract).toLowerCase();
|
||||
if (!this.contracts[contract])
|
||||
this.contracts[contract] = {};
|
||||
if (!this.evContracts[contract])
|
||||
this.evContracts[contract] = {};
|
||||
for (let fn of abi) {
|
||||
if (fn.type === 'function') {
|
||||
const selector = fnSigHash(fn);
|
||||
const value = {
|
||||
name: fn.name || 'function',
|
||||
signature: fnSignature(fn),
|
||||
packer: fn.inputs && fn.inputs.length ? mapArgs(fn.inputs) : undefined,
|
||||
hint: fn.hint,
|
||||
hook: fn.hook,
|
||||
};
|
||||
this.contracts[contract][selector] = value;
|
||||
if (!this.sighashes[selector])
|
||||
this.sighashes[selector] = [];
|
||||
this.sighashes[selector].push(value);
|
||||
}
|
||||
else if (fn.type === 'event') {
|
||||
if (fn.anonymous || !fn.name)
|
||||
continue;
|
||||
const selector = evSigHash(fn);
|
||||
const value = {
|
||||
name: fn.name,
|
||||
signature: fnSignature(fn),
|
||||
decoder: ev[fn.name]?.decode,
|
||||
hint: fn.hint,
|
||||
};
|
||||
this.evContracts[contract][selector] = value;
|
||||
if (!this.evSighashes[selector])
|
||||
this.evSighashes[selector] = [];
|
||||
this.evSighashes[selector].push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
method(contract, data) {
|
||||
contract = strip0x(contract).toLowerCase();
|
||||
const sh = bytesToHex(data.slice(0, 4));
|
||||
if (!this.contracts[contract] || !this.contracts[contract][sh])
|
||||
return;
|
||||
const { name } = this.contracts[contract][sh];
|
||||
return name;
|
||||
}
|
||||
// Returns: exact match, possible options of matches (array) or undefined.
|
||||
// Note that empty value possible if there is no arguments in call.
|
||||
decode(contract, _data, opt) {
|
||||
contract = strip0x(contract).toLowerCase();
|
||||
const sh = bytesToHex(_data.slice(0, 4));
|
||||
const data = _data.slice(4);
|
||||
if (this.contracts[contract] && this.contracts[contract][sh]) {
|
||||
let { name, signature, packer, hint, hook } = this.contracts[contract][sh];
|
||||
const value = packer ? packer.decode(data) : undefined;
|
||||
let res = { name, signature, value };
|
||||
// NOTE: hint && hook fn is used only on exact match of contract!
|
||||
if (hook)
|
||||
res = hook(this, contract, res, opt);
|
||||
try {
|
||||
if (hint)
|
||||
res.hint = hint(value, Object.assign({ contract: add0x(contract) }, opt));
|
||||
}
|
||||
catch (e) { }
|
||||
return res;
|
||||
}
|
||||
if (!this.sighashes[sh] || !this.sighashes[sh].length)
|
||||
return;
|
||||
let res = [];
|
||||
for (let { name, signature, packer } of this.sighashes[sh]) {
|
||||
try {
|
||||
res.push({ name, signature, value: packer ? packer.decode(data) : undefined });
|
||||
}
|
||||
catch (err) { }
|
||||
}
|
||||
if (res.length)
|
||||
return res;
|
||||
return;
|
||||
}
|
||||
decodeEvent(contract, topics, data, opt) {
|
||||
contract = strip0x(contract).toLowerCase();
|
||||
if (!topics.length)
|
||||
return;
|
||||
const sh = strip0x(topics[0]);
|
||||
const event = this.evContracts[contract];
|
||||
if (event && event[sh]) {
|
||||
let { name, signature, decoder, hint } = event[sh];
|
||||
const value = decoder(topics, data);
|
||||
let res = { name, signature, value };
|
||||
try {
|
||||
if (hint)
|
||||
res.hint = hint(value, Object.assign({ contract: add0x(contract) }, opt));
|
||||
}
|
||||
catch (e) { }
|
||||
return res;
|
||||
}
|
||||
if (!this.evSighashes[sh] || !this.evSighashes[sh].length)
|
||||
return;
|
||||
let res = [];
|
||||
for (let { name, signature, decoder } of this.evSighashes[sh]) {
|
||||
try {
|
||||
res.push({ name, signature, value: decoder(topics, data) });
|
||||
}
|
||||
catch (err) { }
|
||||
}
|
||||
if (res.length)
|
||||
return res;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=decoder.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/decoder.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
189
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.d.ts
generated
vendored
Executable file
189
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.d.ts
generated
vendored
Executable file
@@ -0,0 +1,189 @@
|
||||
declare const ABI: readonly [{
|
||||
readonly name: "ApprovalForAll";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "account";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "approved";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "TransferBatch";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "ids";
|
||||
readonly type: "uint256[]";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "values";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "TransferSingle";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "id";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "URI";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly name: "value";
|
||||
readonly type: "string";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "id";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "balanceOf";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "account";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "id";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "balanceOfBatch";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "accounts";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly name: "ids";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "isApprovedForAll";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "account";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "safeBatchTransferFrom";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "ids";
|
||||
readonly type: "uint256[]";
|
||||
}, {
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}, {
|
||||
readonly name: "data";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly outputs: readonly [];
|
||||
}, {
|
||||
readonly name: "safeTransferFrom";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "id";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "amount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "data";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly outputs: readonly [];
|
||||
}, {
|
||||
readonly name: "setApprovalForAll";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "approved";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
readonly outputs: readonly [];
|
||||
}, {
|
||||
readonly name: "supportsInterface";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "interfaceId";
|
||||
readonly type: "bytes4";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "uri";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "id";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}];
|
||||
export default ABI;
|
||||
//# sourceMappingURL=erc1155.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"erc1155.d.ts","sourceRoot":"","sources":["../../src/abi/erc1155.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEC,CAAC;AAEX,eAAe,GAAG,CAAC"}
|
||||
7
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.js
generated
vendored
Executable file
7
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.js
generated
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
// Multi Token Standard https://eips.ethereum.org/EIPS/eip-1155
|
||||
// prettier-ignore
|
||||
const ABI = [
|
||||
{ name: 'ApprovalForAll', type: 'event', inputs: [{ indexed: true, name: 'account', type: 'address' }, { indexed: true, name: 'operator', type: 'address' }, { indexed: false, name: 'approved', type: 'bool' },], }, { name: 'TransferBatch', type: 'event', inputs: [{ indexed: true, name: 'operator', type: 'address' }, { indexed: true, name: 'from', type: 'address' }, { indexed: true, name: 'to', type: 'address' }, { indexed: false, name: 'ids', type: 'uint256[]' }, { indexed: false, name: 'values', type: 'uint256[]' },], }, { name: 'TransferSingle', type: 'event', inputs: [{ indexed: true, name: 'operator', type: 'address' }, { indexed: true, name: 'from', type: 'address' }, { indexed: true, name: 'to', type: 'address' }, { indexed: false, name: 'id', type: 'uint256' }, { indexed: false, name: 'value', type: 'uint256' },], }, { name: 'URI', type: 'event', inputs: [{ indexed: false, name: 'value', type: 'string' }, { indexed: true, name: 'id', type: 'uint256' },], }, { name: 'balanceOf', type: 'function', inputs: [{ name: 'account', type: 'address' }, { name: 'id', type: 'uint256' },], outputs: [{ type: 'uint256' }], }, { name: 'balanceOfBatch', type: 'function', inputs: [{ name: 'accounts', type: 'address[]' }, { name: 'ids', type: 'uint256[]' },], outputs: [{ type: 'uint256[]' }], }, { name: 'isApprovedForAll', type: 'function', inputs: [{ name: 'account', type: 'address' }, { name: 'operator', type: 'address' },], outputs: [{ type: 'bool' }], }, { name: 'safeBatchTransferFrom', type: 'function', inputs: [{ name: 'from', type: 'address' }, { name: 'to', type: 'address' }, { name: 'ids', type: 'uint256[]' }, { name: 'amounts', type: 'uint256[]' }, { name: 'data', type: 'bytes' },], outputs: [], }, { name: 'safeTransferFrom', type: 'function', inputs: [{ name: 'from', type: 'address' }, { name: 'to', type: 'address' }, { name: 'id', type: 'uint256' }, { name: 'amount', type: 'uint256' }, { name: 'data', type: 'bytes' },], outputs: [], }, { name: 'setApprovalForAll', type: 'function', inputs: [{ name: 'operator', type: 'address' }, { name: 'approved', type: 'bool' },], outputs: [], }, { name: 'supportsInterface', type: 'function', inputs: [{ name: 'interfaceId', type: 'bytes4' }], outputs: [{ type: 'bool' }], }, { name: 'uri', type: 'function', inputs: [{ name: 'id', type: 'uint256' }], outputs: [{ type: 'string' }] }
|
||||
];
|
||||
export default ABI;
|
||||
//# sourceMappingURL=erc1155.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc1155.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"erc1155.js","sourceRoot":"","sources":["../../src/abi/erc1155.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,kBAAkB;AAClB,MAAM,GAAG,GAAG;IACV,EAAC,IAAI,EAAC,gBAAgB,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,CAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,KAAK,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM,EAAC,EAAE,GAAE,EAAC,EAAC,IAAI,EAAC,eAAe,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,CAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,KAAK,EAA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M,EAAC,IAAI,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,GAAE,EAAC,EAAC,IAAI,EAAC,mBAAmB,EAAC,IAAI,EAAC,UAAU,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,GAAE,EAAC,EAAC,IAAI,EAAC,mBAAmB,EAAC,IAAI,EAAC,UAAU,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,aAAa,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,MAAM,EAAC,CAAC,GAAE,EAAC,EAAC,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,UAAU,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,EAAC;CACx8D,CAAC;AAEX,eAAe,GAAG,CAAC"}
|
||||
308
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.d.ts
generated
vendored
Executable file
308
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.d.ts
generated
vendored
Executable file
@@ -0,0 +1,308 @@
|
||||
import { type HintOpt } from './decoder.ts';
|
||||
export declare const ABI: readonly [{
|
||||
readonly type: "function";
|
||||
readonly name: "name";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "totalSupply";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "decimals";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "symbol";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "approve";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "transferFrom";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "balances";
|
||||
readonly inputs: readonly [{
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "allowed";
|
||||
readonly inputs: readonly [{
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "balanceOf";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "balance";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "transfer";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "allowance";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "remaining";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "Approval";
|
||||
readonly type: "event";
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "Transfer";
|
||||
readonly type: "event";
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}];
|
||||
export declare const hints: {
|
||||
approve(v: any, opt: HintOpt): string;
|
||||
transferFrom(v: any, opt: HintOpt): string;
|
||||
transfer(v: any, opt: HintOpt): string;
|
||||
Approval(v: any, opt: HintOpt): string;
|
||||
Transfer(v: any, opt: HintOpt): string;
|
||||
};
|
||||
declare const ERC20ABI: readonly [{
|
||||
readonly type: "function";
|
||||
readonly name: "name";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "totalSupply";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "decimals";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "symbol";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "approve";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "transferFrom";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "balances";
|
||||
readonly inputs: readonly [{
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "allowed";
|
||||
readonly inputs: readonly [{
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "balanceOf";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "balance";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "transfer";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "allowance";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "remaining";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "Approval";
|
||||
readonly type: "event";
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "Transfer";
|
||||
readonly type: "event";
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}];
|
||||
export default ERC20ABI;
|
||||
//# sourceMappingURL=erc20.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../src/abi/erc20.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEN,CAAC;AAGX,eAAO,MAAM,KAAK;eACL,GAAG,OAAO,OAAO;oBAQZ,GAAG,OAAO,OAAO;gBAQrB,GAAG,OAAO,OAAO;gBAOjB,GAAG,OAAO,OAAO;gBAOjB,GAAG,OAAO,OAAO;CAO9B,CAAC;AAEF,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuC,CAAC;AACtD,eAAe,QAAQ,CAAC"}
|
||||
38
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.js
generated
vendored
Executable file
38
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.js
generated
vendored
Executable file
@@ -0,0 +1,38 @@
|
||||
import { createDecimal } from "../utils.js";
|
||||
import { addHints } from "./common.js";
|
||||
import {} from "./decoder.js";
|
||||
// prettier-ignore
|
||||
export const ABI = [
|
||||
{ type: "function", name: "name", outputs: [{ type: "string" }] }, { type: "function", name: "totalSupply", outputs: [{ type: "uint256" }] }, { type: "function", name: "decimals", outputs: [{ type: "uint8" }] }, { type: "function", name: "symbol", outputs: [{ type: "string" }] }, { type: "function", name: "approve", inputs: [{ name: "spender", type: "address" }, { name: "value", type: "uint256" }], outputs: [{ name: "success", type: "bool" }] }, { type: "function", name: "transferFrom", inputs: [{ name: "from", type: "address" }, { name: "to", type: "address" }, { name: "value", type: "uint256" }], outputs: [{ name: "success", type: "bool" }] }, { type: "function", name: "balances", inputs: [{ type: "address" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "allowed", inputs: [{ type: "address" }, { type: "address" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "balanceOf", inputs: [{ name: "owner", type: "address" }], outputs: [{ name: "balance", type: "uint256" }] }, { type: "function", name: "transfer", inputs: [{ name: "to", type: "address" }, { name: "value", type: "uint256" }], outputs: [{ name: "success", type: "bool" }] }, { type: "function", name: "allowance", inputs: [{ name: "owner", type: "address" }, { name: "spender", type: "address" }], outputs: [{ name: "remaining", type: "uint256" }] }, { name: "Approval", type: "event", anonymous: false, inputs: [{ indexed: true, name: "owner", type: "address" }, { indexed: true, name: "spender", type: "address" }, { indexed: false, name: "value", type: "uint256" }] }, { name: "Transfer", type: "event", anonymous: false, inputs: [{ indexed: true, name: "from", type: "address" }, { indexed: true, name: "to", type: "address" }, { indexed: false, name: "value", type: "uint256" }] }
|
||||
];
|
||||
// https://eips.ethereum.org/EIPS/eip-20
|
||||
export const hints = {
|
||||
approve(v, opt) {
|
||||
if (!opt.contractInfo || !opt.contractInfo.decimals || !opt.contractInfo.symbol)
|
||||
throw new Error('Not enough info');
|
||||
return `Allow spending ${createDecimal(opt.contractInfo.decimals).encode(v.value)} ${opt.contractInfo.symbol} by ${v.spender}`;
|
||||
},
|
||||
transferFrom(v, opt) {
|
||||
if (!opt.contractInfo || !opt.contractInfo.decimals || !opt.contractInfo.symbol)
|
||||
throw new Error('Not enough info');
|
||||
return `Transfer ${createDecimal(opt.contractInfo.decimals).encode(v.value)} ${opt.contractInfo.symbol} from ${v.from} to ${v.to}`;
|
||||
},
|
||||
transfer(v, opt) {
|
||||
if (!opt.contractInfo || !opt.contractInfo.decimals || !opt.contractInfo.symbol)
|
||||
throw new Error('Not enough info');
|
||||
return `Transfer ${createDecimal(opt.contractInfo.decimals).encode(v.value)} ${opt.contractInfo.symbol} to ${v.to}`;
|
||||
},
|
||||
Approval(v, opt) {
|
||||
if (!opt.contractInfo || !opt.contractInfo.decimals || !opt.contractInfo.symbol)
|
||||
throw new Error('Not enough info');
|
||||
return `Allow ${v.spender} spending up to ${createDecimal(opt.contractInfo.decimals).encode(v.value)} ${opt.contractInfo.symbol} from ${v.owner}`;
|
||||
},
|
||||
Transfer(v, opt) {
|
||||
if (!opt.contractInfo || !opt.contractInfo.decimals || !opt.contractInfo.symbol)
|
||||
throw new Error('Not enough info');
|
||||
return `Transfer ${createDecimal(opt.contractInfo.decimals).encode(v.value)} ${opt.contractInfo.symbol} from ${v.from} to ${v.to}`;
|
||||
},
|
||||
};
|
||||
const ERC20ABI = /* @__PURE__ */ addHints(ABI, hints);
|
||||
export default ERC20ABI;
|
||||
//# sourceMappingURL=erc20.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc20.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/abi/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAgB,MAAM,cAAc,CAAC;AAE5C,kBAAkB;AAClB,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,aAAa,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,UAAU,EAAC,OAAO,EAAC,CAAC,EAAC,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AAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACtD,eAAe,QAAQ,CAAC"}
|
||||
220
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.d.ts
generated
vendored
Executable file
220
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.d.ts
generated
vendored
Executable file
@@ -0,0 +1,220 @@
|
||||
declare const ABI: readonly [{
|
||||
readonly type: "function";
|
||||
readonly name: "approve";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "approved";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "balanceOf";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "ownerOf";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "getApproved";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "address";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "isApprovedForAll";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "safeTransferFrom";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "safeTransferFrom";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "data";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "setApprovalForAll";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "operator";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "approved";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "supportsInterface";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "interfaceID";
|
||||
readonly type: "bytes4";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "transferFrom";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "tokenByIndex";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "index";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "tokenOfOwnerByIndex";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "index";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "totalSupply";
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "name";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "name";
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "symbol";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "symbol";
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "tokenURI";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "Transfer";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "from";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "Approval";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "tokenId";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "ApprovalForAll";
|
||||
readonly type: "event";
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "owner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "spender";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "approved";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
}];
|
||||
export default ABI;
|
||||
//# sourceMappingURL=erc721.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../src/abi/erc721.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEC,CAAC;AAEX,eAAe,GAAG,CAAC"}
|
||||
7
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.js
generated
vendored
Executable file
7
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.js
generated
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
// Non-Fungible Token Standard: https://eips.ethereum.org/EIPS/eip-721
|
||||
// prettier-ignore
|
||||
const ABI = [
|
||||
{ type: "function", name: "approve", inputs: [{ name: "approved", type: "address" }, { name: "tokenId", type: "uint256" }] }, { type: "function", name: "balanceOf", inputs: [{ name: "owner", type: "address" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "ownerOf", inputs: [{ name: "tokenId", type: "uint256" }], outputs: [{ name: "owner", type: "address" }] }, { type: "function", name: "getApproved", inputs: [{ name: "tokenId", type: "uint256" }], outputs: [{ type: "address" }] }, { type: "function", name: "isApprovedForAll", inputs: [{ name: "owner", type: "address" }, { name: "operator", type: "address" }], outputs: [{ type: "bool" }] }, { type: "function", name: "safeTransferFrom", inputs: [{ name: "from", type: "address" }, { name: "to", type: "address" }, { name: "tokenId", type: "uint256" }] }, { type: "function", name: "safeTransferFrom", inputs: [{ name: "from", type: "address" }, { name: "to", type: "address" }, { name: "tokenId", type: "uint256" }, { name: "data", type: "bytes" }] }, { type: "function", name: "setApprovalForAll", inputs: [{ name: "operator", type: "address" }, { name: "approved", type: "bool" }] }, { type: "function", name: "supportsInterface", inputs: [{ name: "interfaceID", type: "bytes4" }], outputs: [{ type: "bool" }] }, { type: "function", name: "transferFrom", inputs: [{ name: "from", type: "address" }, { name: "to", type: "address" }, { name: "tokenId", type: "uint256" }] }, { type: "function", name: "tokenByIndex", inputs: [{ name: "index", type: "uint256" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "tokenOfOwnerByIndex", inputs: [{ name: "owner", type: "address" }, { name: "index", type: "uint256" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "totalSupply", outputs: [{ type: "uint256" }] }, { type: "function", name: "name", outputs: [{ name: "name", type: "string" }] }, { type: "function", name: "symbol", outputs: [{ name: "symbol", type: "string" }] }, { type: "function", name: "tokenURI", inputs: [{ name: "tokenId", type: "uint256" }], outputs: [{ type: "string" }] }, { name: "Transfer", type: "event", inputs: [{ indexed: true, name: "from", type: "address" }, { indexed: true, name: "to", type: "address" }, { indexed: true, name: "tokenId", type: "uint256" }] }, { name: "Approval", type: "event", inputs: [{ indexed: true, name: "owner", type: "address" }, { indexed: true, name: "spender", type: "address" }, { indexed: true, name: "tokenId", type: "uint256" }] }, { name: "ApprovalForAll", type: "event", inputs: [{ indexed: true, name: "owner", type: "address" }, { indexed: true, name: "spender", type: "address" }, { indexed: false, name: "approved", type: "bool" }] }
|
||||
];
|
||||
export default ABI;
|
||||
//# sourceMappingURL=erc721.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/erc721.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"erc721.js","sourceRoot":"","sources":["../../src/abi/erc721.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,kBAAkB;AAClB,MAAM,GAAG,GAAG;IACV,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,WAAW,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,aAAa,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,kBAAkB,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,SAAS,EA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,UAAU,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,CAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,CAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,EAAC,EAAC,IAAI,EAAC,gBAAgB,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,CAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,OAAO,EAAC,KAAK,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM,EAAC,CAAC,EAAC;CAClvE,CAAC;AAEX,eAAe,GAAG,CAAC"}
|
||||
24
dev/env/node_modules/micro-eth-signer/esm/abi/index.d.ts
generated
vendored
Executable file
24
dev/env/node_modules/micro-eth-signer/esm/abi/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,24 @@
|
||||
import { type ContractABI, type ContractInfo, Decoder, createContract, deployContract, events } from './decoder.ts';
|
||||
import { default as ERC1155 } from './erc1155.ts';
|
||||
import { default as ERC20 } from './erc20.ts';
|
||||
import { default as ERC721 } from './erc721.ts';
|
||||
import { KYBER_NETWORK_PROXY_CONTRACT } from './kyber.ts';
|
||||
import { UNISWAP_V2_ROUTER_CONTRACT } from './uniswap-v2.ts';
|
||||
import { UNISWAP_V3_ROUTER_CONTRACT } from './uniswap-v3.ts';
|
||||
import { default as WETH } from './weth.ts';
|
||||
export { ERC1155, ERC20, ERC721, KYBER_NETWORK_PROXY_CONTRACT, UNISWAP_V2_ROUTER_CONTRACT, UNISWAP_V3_ROUTER_CONTRACT, WETH, };
|
||||
export { Decoder, createContract, deployContract, events };
|
||||
export type { ContractABI, ContractInfo };
|
||||
export declare const TOKENS: Record<string, ContractInfo>;
|
||||
export declare const CONTRACTS: Record<string, ContractInfo>;
|
||||
export declare const tokenFromSymbol: (symbol: string) => {
|
||||
contract: string;
|
||||
} & ContractInfo;
|
||||
export type DecoderOpt = {
|
||||
customContracts?: Record<string, ContractInfo>;
|
||||
noDefault?: boolean;
|
||||
};
|
||||
export declare const decodeData: (to: string, data: string, amount?: bigint, opt?: DecoderOpt) => import("./decoder.ts").SignatureInfo | import("./decoder.ts").SignatureInfo[] | undefined;
|
||||
export declare const decodeTx: (transaction: string, opt?: DecoderOpt) => import("./decoder.ts").SignatureInfo | import("./decoder.ts").SignatureInfo[] | undefined;
|
||||
export declare const decodeEvent: (to: string, topics: string[], data: string, opt?: DecoderOpt) => import("./decoder.ts").SignatureInfo | import("./decoder.ts").SignatureInfo[] | undefined;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/index.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/index.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abi/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,WAAW,EAChB,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AIF,eAAO,MAAM,QAAQ,GAAI,aAAa,MAAM,EAAE,MAAK,UAAe,8FAGjE,CAAC;AAGF,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,EAAE,QAAQ,MAAM,EAAE,EAAE,MAAM,MAAM,EAAE,MAAK,UAAe,8FAS3F,CAAC"}
|
||||
127
dev/env/node_modules/micro-eth-signer/esm/abi/index.js
generated
vendored
Executable file
127
dev/env/node_modules/micro-eth-signer/esm/abi/index.js
generated
vendored
Executable file
@@ -0,0 +1,127 @@
|
||||
import { addr } from "../address.js";
|
||||
import { Transaction } from "../index.js";
|
||||
import { ethHex } from "../utils.js";
|
||||
import { Decoder, createContract, deployContract, events, } from "./decoder.js";
|
||||
import { default as ERC1155 } from "./erc1155.js";
|
||||
import { default as ERC20 } from "./erc20.js";
|
||||
import { default as ERC721 } from "./erc721.js";
|
||||
import { default as KYBER_NETWORK_PROXY, KYBER_NETWORK_PROXY_CONTRACT } from "./kyber.js";
|
||||
import { default as UNISWAP_V2_ROUTER, UNISWAP_V2_ROUTER_CONTRACT } from "./uniswap-v2.js";
|
||||
import { default as UNISWAP_V3_ROUTER, UNISWAP_V3_ROUTER_CONTRACT } from "./uniswap-v3.js";
|
||||
import { default as WETH, WETH_CONTRACT } from "./weth.js";
|
||||
// We need to export raw contracts, because 'CONTRACTS' object requires to know address it is not static type
|
||||
// so it cannot be re-used in createContract with nice types.
|
||||
export { ERC1155, ERC20, ERC721, KYBER_NETWORK_PROXY_CONTRACT, UNISWAP_V2_ROUTER_CONTRACT, UNISWAP_V3_ROUTER_CONTRACT, WETH, };
|
||||
export { Decoder, createContract, deployContract, events };
|
||||
export const TOKENS = /* @__PURE__ */ (() => Object.freeze(Object.fromEntries([
|
||||
['UNI', '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984'],
|
||||
['BAT', '0x0d8775f648430679a709e98d2b0cb6250d2887ef'],
|
||||
// Required for Uniswap multi-hop routing
|
||||
['USDT', '0xdac17f958d2ee523a2206206994597c13d831ec7', 6, 1],
|
||||
['USDC', '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 6, 1],
|
||||
['WETH', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'],
|
||||
['WBTC', '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', 8],
|
||||
['DAI', '0x6b175474e89094c44da98b954eedeac495271d0f', 18, 1],
|
||||
['COMP', '0xc00e94cb662c3520282e6f5717214004a7f26888'],
|
||||
['MKR', '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2'],
|
||||
['AMPL', '0xd46ba6d942050d489dbd938a2c909a5d5039a161', 9],
|
||||
].map(([symbol, addr, decimals, price]) => [
|
||||
addr,
|
||||
{ abi: 'ERC20', symbol, decimals: decimals || 18, price },
|
||||
]))))();
|
||||
// <address, contractInfo>
|
||||
export const CONTRACTS = /* @__PURE__ */ (() => Object.freeze({
|
||||
[UNISWAP_V2_ROUTER_CONTRACT]: { abi: UNISWAP_V2_ROUTER, name: 'UNISWAP V2 ROUTER' },
|
||||
[KYBER_NETWORK_PROXY_CONTRACT]: { abi: KYBER_NETWORK_PROXY, name: 'KYBER NETWORK PROXY' },
|
||||
[UNISWAP_V3_ROUTER_CONTRACT]: { abi: UNISWAP_V3_ROUTER, name: 'UNISWAP V3 ROUTER' },
|
||||
...TOKENS,
|
||||
[WETH_CONTRACT]: { abi: WETH, name: 'WETH Token', decimals: 18, symbol: 'WETH' },
|
||||
}))();
|
||||
export const tokenFromSymbol = (symbol) => {
|
||||
for (let c in TOKENS) {
|
||||
if (TOKENS[c].symbol === symbol)
|
||||
return Object.assign({ contract: c }, TOKENS[c]);
|
||||
}
|
||||
throw new Error('unknown token');
|
||||
};
|
||||
const getABI = (info) => {
|
||||
if (typeof info.abi === 'string') {
|
||||
if (info.abi === 'ERC20')
|
||||
return ERC20;
|
||||
else if (info.abi === 'ERC721')
|
||||
return ERC721;
|
||||
else
|
||||
throw new Error(`getABI: unknown abi type=${info.abi}`);
|
||||
}
|
||||
return info.abi;
|
||||
};
|
||||
// TODO: export? Seems useful enough
|
||||
// We cannot have this inside decoder itself,
|
||||
// since it will create dependencies on all default contracts
|
||||
const getDecoder = (opt = {}) => {
|
||||
const decoder = new Decoder();
|
||||
const contracts = {};
|
||||
// Add contracts
|
||||
if (!opt.noDefault)
|
||||
Object.assign(contracts, CONTRACTS);
|
||||
if (opt.customContracts) {
|
||||
for (const k in opt.customContracts)
|
||||
contracts[k.toLowerCase()] = opt.customContracts[k];
|
||||
}
|
||||
// Contract info validation
|
||||
for (const k in contracts) {
|
||||
if (!addr.isValid(k))
|
||||
throw new Error(`getDecoder: invalid contract address=${k}`);
|
||||
const c = contracts[k];
|
||||
if (c.symbol !== undefined && typeof c.symbol !== 'string')
|
||||
throw new Error(`getDecoder: wrong symbol type=${c.symbol}`);
|
||||
if (c.decimals !== undefined && !Number.isSafeInteger(c.decimals))
|
||||
throw new Error(`getDecoder: wrong decimals type=${c.decimals}`);
|
||||
if (c.name !== undefined && typeof c.name !== 'string')
|
||||
throw new Error(`getDecoder: wrong name type=${c.name}`);
|
||||
if (c.price !== undefined && typeof c.price !== 'number')
|
||||
throw new Error(`getDecoder: wrong price type=${c.price}`);
|
||||
decoder.add(k, getABI(c)); // validates c.abi
|
||||
}
|
||||
return { decoder, contracts };
|
||||
};
|
||||
// These methods are for case when user wants to inspect tx/logs/receipt,
|
||||
// but doesn't know anything about which contract is used. If you work with
|
||||
// specific contract it is better to use 'createContract' which will return nice types.
|
||||
// 'to' can point to specific known contract, but also can point to any address (it is part of tx)
|
||||
// 'to' should be part of real tx you want to parse, not hardcoded contract!
|
||||
// Even if contract is unknown, we still try to process by known function signatures
|
||||
// from other contracts.
|
||||
// Can be used to parse tx or 'eth_getTransactionReceipt' output
|
||||
export const decodeData = (to, data, amount, opt = {}) => {
|
||||
if (!addr.isValid(to))
|
||||
throw new Error(`decodeData: wrong to=${to}`);
|
||||
if (amount !== undefined && typeof amount !== 'bigint')
|
||||
throw new Error(`decodeData: wrong amount=${amount}`);
|
||||
const { decoder, contracts } = getDecoder(opt);
|
||||
return decoder.decode(to, ethHex.decode(data), {
|
||||
contract: to,
|
||||
contracts, // NOTE: we need whole contracts list here, since exchanges can use info about other contracts (tokens)
|
||||
contractInfo: contracts[to.toLowerCase()], // current contract info (for tokens)
|
||||
amount, // Amount is not neccesary, but some hints won't work without it (exchange eth to some tokens)
|
||||
});
|
||||
};
|
||||
// Requires deps on tx, but nicer API.
|
||||
// Doesn't cover all use cases of decodeData, since it can't parse 'eth_getTransactionReceipt'
|
||||
export const decodeTx = (transaction, opt = {}) => {
|
||||
const tx = Transaction.fromHex(transaction);
|
||||
return decodeData(tx.raw.to, tx.raw.data, tx.raw.value, opt);
|
||||
};
|
||||
// Parses output of eth_getLogs/eth_getTransactionReceipt
|
||||
export const decodeEvent = (to, topics, data, opt = {}) => {
|
||||
if (!addr.isValid(to))
|
||||
throw new Error(`decodeEvent: wrong to=${to}`);
|
||||
const { decoder, contracts } = getDecoder(opt);
|
||||
return decoder.decodeEvent(to, topics, data, {
|
||||
contract: to,
|
||||
contracts,
|
||||
contractInfo: contracts[to.toLowerCase()],
|
||||
// amount here is not used by our hooks. Should we ask it for consistency?
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/index.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/index.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
141
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.d.ts
generated
vendored
Executable file
141
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.d.ts
generated
vendored
Executable file
@@ -0,0 +1,141 @@
|
||||
declare const ABI: readonly [{
|
||||
readonly type: "function";
|
||||
readonly name: "getExpectedRate";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "dest";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "srcQty";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "expectedRate";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "worstRate";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "getExpectedRateAfterFee";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "dest";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "srcQty";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "platformFeeBps";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "hint";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "expectedRate";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "trade";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "srcAmount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "dest";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "destAddress";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "maxDestAmount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "minConversionRate";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "platformWallet";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "tradeWithHint";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "srcAmount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "dest";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "destAddress";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "maxDestAmount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "minConversionRate";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "walletId";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "hint";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}, {
|
||||
readonly type: "function";
|
||||
readonly name: "tradeWithHintAndFee";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "srcAmount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "dest";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "destAddress";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "maxDestAmount";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "minConversionRate";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "platformWallet";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "platformFeeBps";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "hint";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "destAmount";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
}];
|
||||
export default ABI;
|
||||
export declare const KYBER_NETWORK_PROXY_CONTRACT = "0x9aab3f75489902f3a48495025729a0af77d4b11e";
|
||||
//# sourceMappingURL=kyber.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"kyber.d.ts","sourceRoot":"","sources":["../../src/abi/kyber.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwC,CAAC;AAElD,eAAe,GAAG,CAAC;AACnB,eAAO,MAAM,4BAA4B,+CAA+C,CAAC"}
|
||||
31
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.js
generated
vendored
Executable file
31
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.js
generated
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
import { createDecimal } from "../utils.js";
|
||||
import { addHints } from "./common.js";
|
||||
import {} from "./decoder.js";
|
||||
// prettier-ignore
|
||||
const _ABI = [
|
||||
{ type: "function", name: "getExpectedRate", inputs: [{ name: "src", type: "address" }, { name: "dest", type: "address" }, { name: "srcQty", type: "uint256" }], outputs: [{ name: "expectedRate", type: "uint256" }, { name: "worstRate", type: "uint256" }] }, { type: "function", name: "getExpectedRateAfterFee", inputs: [{ name: "src", type: "address" }, { name: "dest", type: "address" }, { name: "srcQty", type: "uint256" }, { name: "platformFeeBps", type: "uint256" }, { name: "hint", type: "bytes" }], outputs: [{ name: "expectedRate", type: "uint256" }] }, { type: "function", name: "trade", inputs: [{ name: "src", type: "address" }, { name: "srcAmount", type: "uint256" }, { name: "dest", type: "address" }, { name: "destAddress", type: "address" }, { name: "maxDestAmount", type: "uint256" }, { name: "minConversionRate", type: "uint256" }, { name: "platformWallet", type: "address" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "tradeWithHint", inputs: [{ name: "src", type: "address" }, { name: "srcAmount", type: "uint256" }, { name: "dest", type: "address" }, { name: "destAddress", type: "address" }, { name: "maxDestAmount", type: "uint256" }, { name: "minConversionRate", type: "uint256" }, { name: "walletId", type: "address" }, { name: "hint", type: "bytes" }], outputs: [{ type: "uint256" }] }, { type: "function", name: "tradeWithHintAndFee", inputs: [{ name: "src", type: "address" }, { name: "srcAmount", type: "uint256" }, { name: "dest", type: "address" }, { name: "destAddress", type: "address" }, { name: "maxDestAmount", type: "uint256" }, { name: "minConversionRate", type: "uint256" }, { name: "platformWallet", type: "address" }, { name: "platformFeeBps", type: "uint256" }, { name: "hint", type: "bytes" }], outputs: [{ name: "destAmount", type: "uint256" }] }
|
||||
];
|
||||
const _10n = BigInt(10);
|
||||
const hints = {
|
||||
tradeWithHintAndFee(v, opt) {
|
||||
if (!opt.contracts)
|
||||
throw Error('Not enough info');
|
||||
const tokenInfo = (c) => c === '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
|
||||
? { symbol: 'ETH', decimals: 18 }
|
||||
: opt.contracts[c];
|
||||
const formatToken = (amount, info) => `${createDecimal(info.decimals).encode(amount)} ${info.symbol}`;
|
||||
const [srcInfo, destInfo] = [tokenInfo(v.src), tokenInfo(v.dest)];
|
||||
if (!srcInfo || !destInfo)
|
||||
throw Error('Not enough info');
|
||||
const destAmount = (v.srcAmount *
|
||||
v.minConversionRate *
|
||||
_10n ** BigInt(destInfo.decimals)) /
|
||||
_10n ** (BigInt(srcInfo.decimals) + BigInt(18));
|
||||
const fee = formatToken((BigInt(v.platformFeeBps) * BigInt(v.srcAmount)) / BigInt(10000), srcInfo);
|
||||
return `Swap ${formatToken(v.srcAmount, srcInfo)} For ${formatToken(destAmount, destInfo)} (with platform fee: ${fee})`;
|
||||
},
|
||||
};
|
||||
const ABI = /* @__PURE__ */ addHints(_ABI, hints);
|
||||
export default ABI;
|
||||
export const KYBER_NETWORK_PROXY_CONTRACT = '0x9aab3f75489902f3a48495025729a0af77d4b11e';
|
||||
//# sourceMappingURL=kyber.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/kyber.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||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C,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ;YAAE,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC1D,MAAM,UAAU,GACd,CAAE,CAAC,CAAC,SAAoB;YACrB,CAAC,CAAC,iBAA4B;YAC/B,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAS,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAS,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,WAAW,CACrB,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,EAChE,OAAO,CACR,CAAC;QACF,OAAO,QAAQ,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,WAAW,CACjE,UAAU,EACV,QAAQ,CACT,wBAAwB,GAAG,GAAG,CAAC;IAClC,CAAC;CACF,CAAC;AAEF,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAElD,eAAe,GAAG,CAAC;AACnB,MAAM,CAAC,MAAM,4BAA4B,GAAG,4CAA4C,CAAC"}
|
||||
755
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.d.ts
generated
vendored
Executable file
755
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.d.ts
generated
vendored
Executable file
@@ -0,0 +1,755 @@
|
||||
declare const ABI: readonly [{
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "_factory";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "_WETH";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "constructor";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "WETH";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenA";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenB";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountADesired";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountBDesired";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountAMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountBMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "addLiquidity";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountA";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountB";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountTokenDesired";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountTokenMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETHMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "addLiquidityETH";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountToken";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETH";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "factory";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "reserveIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "reserveOut";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "getAmountIn";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "pure";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "reserveIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "reserveOut";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "getAmountOut";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "pure";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}];
|
||||
readonly name: "getAmountsIn";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}];
|
||||
readonly name: "getAmountsOut";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountA";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "reserveA";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "reserveB";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "quote";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountB";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "pure";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenA";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenB";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountAMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountBMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "removeLiquidity";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountA";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountB";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountTokenMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETHMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "removeLiquidityETH";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountToken";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETH";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountTokenMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETHMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "removeLiquidityETHSupportingFeeOnTransferTokens";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETH";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountTokenMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETHMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "approveMax";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "removeLiquidityETHWithPermit";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountToken";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETH";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountTokenMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETHMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "approveMax";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountETH";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenA";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenB";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "liquidity";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountAMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountBMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "approveMax";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "removeLiquidityWithPermit";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountA";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountB";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapETHForExactTokens";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapExactETHForTokens";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapExactETHForTokensSupportingFeeOnTransferTokens";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapExactTokensForETH";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapExactTokensForETHSupportingFeeOnTransferTokens";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapExactTokensForTokens";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMin";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapExactTokensForTokensSupportingFeeOnTransferTokens";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountInMax";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapTokensForExactETH";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountInMax";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address[]";
|
||||
readonly name: "path";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "to";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "swapTokensForExactTokens";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256[]";
|
||||
readonly name: "amounts";
|
||||
readonly type: "uint256[]";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "receive";
|
||||
}];
|
||||
export default ABI;
|
||||
export declare const UNISWAP_V2_ROUTER_CONTRACT = "0x7a250d5630b4cf539739df2c5dacb4c659f2488d";
|
||||
//# sourceMappingURL=uniswap-v2.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"uniswap-v2.d.ts","sourceRoot":"","sources":["../../src/abi/uniswap-v2.ts"],"names":[],"mappings":"AAsFA,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwC,CAAC;AAClD,eAAe,GAAG,CAAC;AACnB,eAAO,MAAM,0BAA0B,+CAA+C,CAAC"}
|
||||
80
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.js
generated
vendored
Executable file
80
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.js
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v2.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
441
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.d.ts
generated
vendored
Executable file
441
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.d.ts
generated
vendored
Executable file
@@ -0,0 +1,441 @@
|
||||
declare const ABI: readonly [{
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "_factory";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "_WETH9";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "constructor";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "WETH9";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "path";
|
||||
readonly type: "bytes";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMinimum";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly internalType: "struct ISwapRouter.ExactInputParams";
|
||||
readonly name: "params";
|
||||
readonly type: "tuple";
|
||||
}];
|
||||
readonly name: "exactInput";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenIn";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenOut";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint24";
|
||||
readonly name: "fee";
|
||||
readonly type: "uint24";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOutMinimum";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint160";
|
||||
readonly name: "sqrtPriceLimitX96";
|
||||
readonly type: "uint160";
|
||||
}];
|
||||
readonly internalType: "struct ISwapRouter.ExactInputSingleParams";
|
||||
readonly name: "params";
|
||||
readonly type: "tuple";
|
||||
}];
|
||||
readonly name: "exactInputSingle";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "path";
|
||||
readonly type: "bytes";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountInMaximum";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly internalType: "struct ISwapRouter.ExactOutputParams";
|
||||
readonly name: "params";
|
||||
readonly type: "tuple";
|
||||
}];
|
||||
readonly name: "exactOutput";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenIn";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "tokenOut";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint24";
|
||||
readonly name: "fee";
|
||||
readonly type: "uint24";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountOut";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountInMaximum";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint160";
|
||||
readonly name: "sqrtPriceLimitX96";
|
||||
readonly type: "uint160";
|
||||
}];
|
||||
readonly internalType: "struct ISwapRouter.ExactOutputSingleParams";
|
||||
readonly name: "params";
|
||||
readonly type: "tuple";
|
||||
}];
|
||||
readonly name: "exactOutputSingle";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountIn";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "factory";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "bytes[]";
|
||||
readonly name: "data";
|
||||
readonly type: "bytes[]";
|
||||
}];
|
||||
readonly name: "multicall";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "bytes[]";
|
||||
readonly name: "results";
|
||||
readonly type: "bytes[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "refundETH";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "selfPermit";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "nonce";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "expiry";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "selfPermitAllowed";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "nonce";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "expiry";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "selfPermitAllowedIfNecessary";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "deadline";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "uint8";
|
||||
readonly name: "v";
|
||||
readonly type: "uint8";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "r";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "s";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly name: "selfPermitIfNecessary";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountMinimum";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "sweepToken";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "token";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountMinimum";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "feeBips";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "feeRecipient";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "sweepTokenWithFee";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "int256";
|
||||
readonly name: "amount0Delta";
|
||||
readonly type: "int256";
|
||||
}, {
|
||||
readonly internalType: "int256";
|
||||
readonly name: "amount1Delta";
|
||||
readonly type: "int256";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "_data";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly name: "uniswapV3SwapCallback";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountMinimum";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "unwrapWETH9";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "amountMinimum";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "recipient";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "feeBips";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "address";
|
||||
readonly name: "feeRecipient";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "unwrapWETH9WithFee";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "receive";
|
||||
}];
|
||||
export default ABI;
|
||||
export declare const UNISWAP_V3_ROUTER_CONTRACT = "0xe592427a0aece92de3edee1f18e0157c05861564";
|
||||
//# sourceMappingURL=uniswap-v3.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"uniswap-v3.d.ts","sourceRoot":"","sources":["../../src/abi/uniswap-v3.ts"],"names":[],"mappings":"AA0EA,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiD,CAAC;AAE3D,eAAe,GAAG,CAAC;AACnB,eAAO,MAAM,0BAA0B,+CAA+C,CAAC"}
|
||||
79
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.js
generated
vendored
Executable file
79
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.js
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/uniswap-v3.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
216
dev/env/node_modules/micro-eth-signer/esm/abi/weth.d.ts
generated
vendored
Executable file
216
dev/env/node_modules/micro-eth-signer/esm/abi/weth.d.ts
generated
vendored
Executable file
@@ -0,0 +1,216 @@
|
||||
declare const ABI: readonly [{
|
||||
readonly constant: true;
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "name";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "string";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "guy";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "approve";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: true;
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "totalSupply";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "dst";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "transferFrom";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "withdraw";
|
||||
readonly outputs: readonly [];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: true;
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "decimals";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: true;
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "balanceOf";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: true;
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "symbol";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "string";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "dst";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "transfer";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: false;
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "deposit";
|
||||
readonly outputs: readonly [];
|
||||
readonly payable: true;
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly constant: true;
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "allowance";
|
||||
readonly outputs: readonly [{
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly payable: false;
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly payable: true;
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "fallback";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "guy";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "Approval";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly name: "dst";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "Transfer";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "dst";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "Deposit";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly name: "src";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly name: "wad";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "Withdrawal";
|
||||
readonly type: "event";
|
||||
}];
|
||||
export default ABI;
|
||||
export declare const WETH_CONTRACT = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
||||
//# sourceMappingURL=weth.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/weth.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/weth.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"weth.d.ts","sourceRoot":"","sources":["../../src/abi/weth.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA6C,CAAC;AACvD,eAAe,GAAG,CAAC;AACnB,eAAO,MAAM,aAAa,+CAA+C,CAAC"}
|
||||
10
dev/env/node_modules/micro-eth-signer/esm/abi/weth.js
generated
vendored
Executable file
10
dev/env/node_modules/micro-eth-signer/esm/abi/weth.js
generated
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
import { addHints } from "./common.js";
|
||||
import { hints as erc20hints } from "./erc20.js";
|
||||
// prettier-ignore
|
||||
const _ABI = [
|
||||
{ constant: true, inputs: [], name: "name", outputs: [{ name: "", type: "string" }], payable: false, stateMutability: "view", type: "function" }, { constant: false, inputs: [{ name: "guy", type: "address" }, { name: "wad", type: "uint256" }], name: "approve", outputs: [{ name: "", type: "bool" }], payable: false, stateMutability: "nonpayable", type: "function" }, { constant: true, inputs: [], name: "totalSupply", outputs: [{ name: "", type: "uint256" }], payable: false, stateMutability: "view", type: "function" }, { constant: false, inputs: [{ name: "src", type: "address" }, { name: "dst", type: "address" }, { name: "wad", type: "uint256" }], name: "transferFrom", outputs: [{ name: "", type: "bool" }], payable: false, stateMutability: "nonpayable", type: "function" }, { constant: false, inputs: [{ name: "wad", type: "uint256" }], name: "withdraw", outputs: [], payable: false, stateMutability: "nonpayable", type: "function" }, { constant: true, inputs: [], name: "decimals", outputs: [{ name: "", type: "uint8" }], payable: false, stateMutability: "view", type: "function" }, { constant: true, inputs: [{ name: "", type: "address" }], name: "balanceOf", outputs: [{ name: "", type: "uint256" }], payable: false, stateMutability: "view", type: "function" }, { constant: true, inputs: [], name: "symbol", outputs: [{ name: "", type: "string" }], payable: false, stateMutability: "view", type: "function" }, { constant: false, inputs: [{ name: "dst", type: "address" }, { name: "wad", type: "uint256" }], name: "transfer", outputs: [{ name: "", type: "bool" }], payable: false, stateMutability: "nonpayable", type: "function" }, { constant: false, inputs: [], name: "deposit", outputs: [], payable: true, stateMutability: "payable", type: "function" }, { constant: true, inputs: [{ name: "", type: "address" }, { name: "", type: "address" }], name: "allowance", outputs: [{ name: "", type: "uint256" }], payable: false, stateMutability: "view", type: "function" }, { payable: true, stateMutability: "payable", type: "fallback" }, { anonymous: false, inputs: [{ indexed: true, name: "src", type: "address" }, { indexed: true, name: "guy", type: "address" }, { indexed: false, name: "wad", type: "uint256" }], name: "Approval", type: "event" }, { anonymous: false, inputs: [{ indexed: true, name: "src", type: "address" }, { indexed: true, name: "dst", type: "address" }, { indexed: false, name: "wad", type: "uint256" }], name: "Transfer", type: "event" }, { anonymous: false, inputs: [{ indexed: true, name: "dst", type: "address" }, { indexed: false, name: "wad", type: "uint256" }], name: "Deposit", type: "event" }, { anonymous: false, inputs: [{ indexed: true, name: "src", type: "address" }, { indexed: false, name: "wad", type: "uint256" }], name: "Withdrawal", type: "event" }
|
||||
];
|
||||
const ABI = /* @__PURE__ */ addHints(_ABI, erc20hints);
|
||||
export default ABI;
|
||||
export const WETH_CONTRACT = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
||||
//# sourceMappingURL=weth.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/abi/weth.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/abi/weth.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"weth.js","sourceRoot":"","sources":["../../src/abi/weth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjD,kBAAkB;AAClB,MAAM,IAAI,GAAG;IACX,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,QAAQ,EAAC,CAAC,EAAC,OAAO,EAAC,KAAK,EAAC,eAAe,EAAC,MAAM,EAAC,IAAI,EAAC,UAAU,EAAC,EAAC,EAAC,QAAQ,EAAC,KAAK,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,SAAS,EAAC,EAAC,EAAC,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM,EAAC,CAAC,EAAC,OAAO,EAAC,KAAK,EAAC,eAAe,EAAC,YAAY,EAAC,IAAI,EAAC,UAAU,EAAC,EAAC,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAC,EAAE,EAAC,IAAI,EAAC,aAAa,EAAC,OAAO,EAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,SAAS,EAAC,CAAC,EAAC,OAAO,EAAC,KAAK,EAAC,eAAe,EAAC,MAAM,EAAC,IAAI,EAAC,UAAU,EAAC,EAAC,EAAC,QAAQ,EAAC,KAAK,EAAC,MAAM,EAAC,CAAC,EAAC,IAAI,EAAC,KAAK,E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AC,IAAI,EAAE,UAAU,CAAC,CAAC;AACvD,eAAe,GAAG,CAAC;AACnB,MAAM,CAAC,MAAM,aAAa,GAAG,4CAA4C,CAAC"}
|
||||
37
dev/env/node_modules/micro-eth-signer/esm/address.d.ts
generated
vendored
Executable file
37
dev/env/node_modules/micro-eth-signer/esm/address.d.ts
generated
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
export declare const addr: {
|
||||
RE: RegExp;
|
||||
parse: (address: string, allowEmpty?: boolean) => {
|
||||
hasPrefix: boolean;
|
||||
data: string;
|
||||
};
|
||||
/**
|
||||
* Address checksum is calculated by hashing with keccak_256.
|
||||
* It hashes *string*, not a bytearray: keccak('beef') not keccak([0xbe, 0xef])
|
||||
* @param nonChecksummedAddress
|
||||
* @param allowEmpty - allows '0x'
|
||||
* @returns checksummed address
|
||||
*/
|
||||
addChecksum: (nonChecksummedAddress: string, allowEmpty?: boolean) => string;
|
||||
/**
|
||||
* Creates address from secp256k1 public key.
|
||||
*/
|
||||
fromPublicKey: (key: string | Uint8Array) => string;
|
||||
/**
|
||||
* Creates address from ETH private key in hex or ui8a format.
|
||||
*/
|
||||
fromPrivateKey: (key: string | Uint8Array) => string;
|
||||
/**
|
||||
* Generates hex string with new random private key and address. Uses CSPRNG internally.
|
||||
*/
|
||||
random(): {
|
||||
privateKey: string;
|
||||
address: string;
|
||||
};
|
||||
/**
|
||||
* Verifies checksum if the address is checksummed.
|
||||
* Always returns true when the address is not checksummed.
|
||||
* @param allowEmpty - allows '0x'
|
||||
*/
|
||||
isValid: (checksummedAddress: string, allowEmpty?: boolean) => boolean;
|
||||
};
|
||||
//# sourceMappingURL=address.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/address.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/address.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,IAAI;QACwC,MAAM;qBAElD,MAAM,2BAEd;QACD,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACd;IAgBD;;;;;;OAMG;yCACkC,MAAM,2BAAuB,MAAM;IAYxE;;OAEG;yBACkB,MAAM,GAAG,UAAU,KAAG,MAAM;IAQjD;;OAEG;0BACmB,MAAM,GAAG,UAAU,KAAG,MAAM;IAKlD;;OAEG;cACO;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAKjD;;;;OAIG;kCAC2B,MAAM,2BAAuB,OAAO;CAcnE,CAAC"}
|
||||
91
dev/env/node_modules/micro-eth-signer/esm/address.js
generated
vendored
Executable file
91
dev/env/node_modules/micro-eth-signer/esm/address.js
generated
vendored
Executable file
@@ -0,0 +1,91 @@
|
||||
/*! micro-eth-signer - MIT License (c) 2021 Paul Miller (paulmillr.com) */
|
||||
import { secp256k1 } from '@noble/curves/secp256k1';
|
||||
import { keccak_256 } from '@noble/hashes/sha3';
|
||||
import { bytesToHex } from '@noble/hashes/utils';
|
||||
import { add0x, astr, ethHex, strip0x } from "./utils.js";
|
||||
export const addr = {
|
||||
RE: /^(0[xX])?([0-9a-fA-F]{40})?$/,
|
||||
parse: (address, allowEmpty = false) => {
|
||||
astr(address);
|
||||
// NOTE: empty address allowed for 'to', but would be mistake for other address fields.
|
||||
// '0x' instead of null/undefined because we don't want to send contract creation tx if user
|
||||
// accidentally missed 'to' field.
|
||||
if (allowEmpty && address === '0x')
|
||||
return { hasPrefix: true, data: '' };
|
||||
const res = address.match(addr.RE) || [];
|
||||
const hasPrefix = res[1] != null;
|
||||
const data = res[2];
|
||||
if (!data) {
|
||||
const len = hasPrefix ? 42 : 40;
|
||||
throw new Error(`address must be ${len}-char hex, got ${address.length}-char ${address}`);
|
||||
}
|
||||
return { hasPrefix, data };
|
||||
},
|
||||
/**
|
||||
* Address checksum is calculated by hashing with keccak_256.
|
||||
* It hashes *string*, not a bytearray: keccak('beef') not keccak([0xbe, 0xef])
|
||||
* @param nonChecksummedAddress
|
||||
* @param allowEmpty - allows '0x'
|
||||
* @returns checksummed address
|
||||
*/
|
||||
addChecksum: (nonChecksummedAddress, allowEmpty = false) => {
|
||||
const low = addr.parse(nonChecksummedAddress, allowEmpty).data.toLowerCase();
|
||||
const hash = bytesToHex(keccak_256(low));
|
||||
let checksummed = '';
|
||||
for (let i = 0; i < low.length; i++) {
|
||||
const hi = Number.parseInt(hash[i], 16);
|
||||
const li = low[i];
|
||||
checksummed += hi <= 7 ? li : li.toUpperCase(); // if char is 9-f, upcase it
|
||||
}
|
||||
return add0x(checksummed);
|
||||
},
|
||||
/**
|
||||
* Creates address from secp256k1 public key.
|
||||
*/
|
||||
fromPublicKey: (key) => {
|
||||
if (!key)
|
||||
throw new Error('invalid public key: ' + key);
|
||||
const pub65b = secp256k1.ProjectivePoint.fromHex(key).toRawBytes(false);
|
||||
const hashed = keccak_256(pub65b.subarray(1, 65));
|
||||
const address = bytesToHex(hashed).slice(24); // slice 24..64
|
||||
return addr.addChecksum(address);
|
||||
},
|
||||
/**
|
||||
* Creates address from ETH private key in hex or ui8a format.
|
||||
*/
|
||||
fromPrivateKey: (key) => {
|
||||
if (typeof key === 'string')
|
||||
key = strip0x(key);
|
||||
return addr.fromPublicKey(secp256k1.getPublicKey(key, false));
|
||||
},
|
||||
/**
|
||||
* Generates hex string with new random private key and address. Uses CSPRNG internally.
|
||||
*/
|
||||
random() {
|
||||
const privateKey = ethHex.encode(secp256k1.utils.randomPrivateKey());
|
||||
return { privateKey, address: addr.fromPrivateKey(privateKey) };
|
||||
},
|
||||
/**
|
||||
* Verifies checksum if the address is checksummed.
|
||||
* Always returns true when the address is not checksummed.
|
||||
* @param allowEmpty - allows '0x'
|
||||
*/
|
||||
isValid: (checksummedAddress, allowEmpty = false) => {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = addr.parse(checksummedAddress, allowEmpty);
|
||||
}
|
||||
catch (error) {
|
||||
return false;
|
||||
}
|
||||
const { data: address, hasPrefix } = parsed;
|
||||
if (!hasPrefix)
|
||||
return false;
|
||||
const low = address.toLowerCase();
|
||||
const upp = address.toUpperCase();
|
||||
if (address === low || address === upp)
|
||||
return true;
|
||||
return addr.addChecksum(low, allowEmpty) === checksummedAddress;
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=address.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/address.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/address.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"address.js","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE,8BAAyD;IAC7D,KAAK,EAAE,CACL,OAAe,EACf,UAAU,GAAG,KAAK,EAIlB,EAAE;QACF,IAAI,CAAC,OAAO,CAAC,CAAC;QACd,uFAAuF;QACvF,4FAA4F;QAC5F,kCAAkC;QAClC,IAAI,UAAU,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACzE,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QACjC,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,C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C,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAClC,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QACpD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,kBAAkB,CAAC;IAClE,CAAC;CACF,CAAC"}
|
||||
108
dev/env/node_modules/micro-eth-signer/esm/index.d.ts
generated
vendored
Executable file
108
dev/env/node_modules/micro-eth-signer/esm/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,108 @@
|
||||
import { addr } from './address.ts';
|
||||
import { type AuthorizationItem, type AuthorizationRequest, type TxCoder, type TxType } from './tx.ts';
|
||||
import { weieth, weigwei } from './utils.ts';
|
||||
export { addr, weieth, weigwei };
|
||||
/**
|
||||
* EIP-7702 Authorizations
|
||||
*/
|
||||
export declare const authorization: {
|
||||
_getHash(req: AuthorizationRequest): Uint8Array;
|
||||
sign(req: AuthorizationRequest, privateKey: string): AuthorizationItem;
|
||||
getAuthority(item: AuthorizationItem): string;
|
||||
};
|
||||
declare const TX_DEFAULTS: {
|
||||
readonly accessList: readonly [];
|
||||
readonly authorizationList: readonly [];
|
||||
readonly chainId: bigint;
|
||||
readonly data: "";
|
||||
readonly gasLimit: bigint;
|
||||
readonly maxPriorityFeePerGas: bigint;
|
||||
readonly type: "eip1559";
|
||||
};
|
||||
type DefaultField = keyof typeof TX_DEFAULTS;
|
||||
type DefaultType = (typeof TX_DEFAULTS)['type'];
|
||||
type DefaultsOptional<T> = {
|
||||
[P in keyof T as P extends DefaultField ? P : never]?: T[P];
|
||||
} & {
|
||||
[P in keyof T as P extends DefaultField ? never : P]: T[P];
|
||||
};
|
||||
type HumanInputInner<T extends TxType> = DefaultsOptional<{
|
||||
type: T;
|
||||
} & TxCoder<T>>;
|
||||
type HumanInputInnerDefault = DefaultsOptional<TxCoder<DefaultType>>;
|
||||
type Required<T> = T extends undefined ? never : T;
|
||||
type HumanInput<T extends TxType | undefined> = T extends undefined ? HumanInputInnerDefault : HumanInputInner<Required<T>>;
|
||||
export declare class Transaction<T extends TxType> {
|
||||
readonly type: T;
|
||||
readonly raw: TxCoder<T>;
|
||||
readonly isSigned: boolean;
|
||||
constructor(type: T, raw: TxCoder<T>, strict?: boolean, allowSignatureFields?: boolean);
|
||||
static prepare<T extends {
|
||||
type: undefined;
|
||||
}>(data: T & HumanInputInnerDefault, strict?: boolean): Transaction<(typeof TX_DEFAULTS)['type']>;
|
||||
static prepare<TT extends TxType, T extends {
|
||||
type: TT;
|
||||
} & HumanInput<TT>>(data: HumanInput<TT>, strict?: boolean): Transaction<T['type']>;
|
||||
/**
|
||||
* Creates transaction which sends whole account balance. Does two things:
|
||||
* 1. `amount = accountBalance - maxFeePerGas * gasLimit`
|
||||
* 2. `maxPriorityFeePerGas = maxFeePerGas`
|
||||
*
|
||||
* Every eth block sets a fee for all its transactions, called base fee.
|
||||
* maxFeePerGas indicates how much gas user is able to spend in the worst case.
|
||||
* If the block's base fee is 5 gwei, while user is able to spend 10 gwei in maxFeePerGas,
|
||||
* the transaction would only consume 5 gwei. That means, base fee is unknown
|
||||
* before the transaction is included in a block.
|
||||
*
|
||||
* By setting priorityFee to maxFee, we make the process deterministic:
|
||||
* `maxFee = 10, maxPriority = 10, baseFee = 5` would always spend 10 gwei.
|
||||
* In the end, the balance would become 0.
|
||||
*
|
||||
* WARNING: using the method would decrease privacy of a transfer, because
|
||||
* payments for services have specific amounts, and not *the whole amount*.
|
||||
* @param accountBalance - account balance in wei
|
||||
* @param burnRemaining - send unspent fee to miners. When false, some "small amount" would remain
|
||||
* @returns new transaction with adjusted amounts
|
||||
*/
|
||||
setWholeAmount(accountBalance: bigint, burnRemaining?: boolean): Transaction<T>;
|
||||
static fromRawBytes(bytes: Uint8Array, strict?: boolean): Transaction<'legacy' | 'eip2930' | 'eip1559' | 'eip4844' | 'eip7702'>;
|
||||
static fromHex(hex: string, strict?: boolean): Transaction<'eip1559' | 'legacy' | 'eip2930' | 'eip4844' | 'eip7702'>;
|
||||
private assertIsSigned;
|
||||
/**
|
||||
* Converts transaction to RLP.
|
||||
* @param includeSignature whether to include signature
|
||||
*/
|
||||
toRawBytes(includeSignature?: boolean): Uint8Array;
|
||||
/**
|
||||
* Converts transaction to hex.
|
||||
* @param includeSignature whether to include signature
|
||||
*/
|
||||
toHex(includeSignature?: boolean): string;
|
||||
/** Calculates keccak-256 hash of signed transaction. Used in block explorers. */
|
||||
get hash(): string;
|
||||
/** Returns sender's address. */
|
||||
get sender(): string;
|
||||
/**
|
||||
* For legacy transactions, but can be used with libraries when yParity presented as v.
|
||||
*/
|
||||
get v(): bigint | undefined;
|
||||
private calcHash;
|
||||
/** Calculates MAXIMUM fee in wei that could be spent. */
|
||||
get fee(): bigint;
|
||||
clone(): Transaction<T>;
|
||||
verifySignature(): boolean;
|
||||
removeSignature(): Transaction<T>;
|
||||
/**
|
||||
* Signs transaction with a private key.
|
||||
* @param privateKey key in hex or Uint8Array format
|
||||
* @param opts extraEntropy will increase security of sig by mixing rfc6979 randomness
|
||||
* @returns new "same" transaction, but signed
|
||||
*/
|
||||
signBy(privateKey: string | Uint8Array, extraEntropy?: boolean | Uint8Array): Transaction<T>;
|
||||
/** Calculates public key and address from signed transaction's signature. */
|
||||
recoverSender(): {
|
||||
publicKey: string;
|
||||
address: string;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/index.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/index.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,MAAM,EAQZ,MAAM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AAC,gBAAgB,GAAE,OAAuB,GAAG,UAAU;IAUjE;;;OAGG;IACH,KAAK,CAAC,gBAAgB,GAAE,OAAuB,GAAG,MAAM;IAGxD,iFAAiF;IACjF,IAAI,IAAI,IAAI,MAAM,CAGjB;IACD,gCAAgC;IAChC,IAAI,MAAM,IAAI,MAAM,CAEnB;IACD;;OAEG;IACH,IAAI,CAAC,IAAI,MAAM,GAAG,SAAS,CAE1B;IACD,OAAO,CAAC,QAAQ;IAGhB,yDAAyD;IACzD,IAAI,GAAG,IAAI,MAAM,CAgBhB;IACD,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC;IAGvB,eAAe,IAAI,OAAO;IAS1B,eAAe,IAAI,WAAW,CAAC,CAAC,CAAC;IAGjC;;;;;OAKG;IACH,MAAM,CACJ,UAAU,EAAE,MAAM,GAAG,UAAU,EAC/B,YAAY,GAAE,OAAO,GAAG,UAAiB,GACxC,WAAW,CAAC,CAAC,CAAC;IASjB,6EAA6E;IAC7E,aAAa,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CASxD"}
|
||||
223
dev/env/node_modules/micro-eth-signer/esm/index.js
generated
vendored
Executable file
223
dev/env/node_modules/micro-eth-signer/esm/index.js
generated
vendored
Executable file
@@ -0,0 +1,223 @@
|
||||
/*! micro-eth-signer - MIT License (c) 2021 Paul Miller (paulmillr.com) */
|
||||
import { keccak_256 } from '@noble/hashes/sha3';
|
||||
import { bytesToHex, concatBytes, hexToBytes } from '@noble/hashes/utils';
|
||||
import { addr } from "./address.js";
|
||||
// prettier-ignore
|
||||
import { RLP } from "./rlp.js";
|
||||
import { RawTx, TxVersions, authorizationRequest, decodeLegacyV, removeSig, sortRawData, validateFields, } from "./tx.js";
|
||||
// prettier-ignore
|
||||
import { amounts, astr, cloneDeep, ethHex, ethHexNoLeadingZero, initSig, isBytes, sign, strip0x, verify, weieth, weigwei } from "./utils.js";
|
||||
export { addr, weieth, weigwei };
|
||||
// The file exports Transaction, but actual (RLP) parsing logic is done in `./tx`
|
||||
/**
|
||||
* EIP-7702 Authorizations
|
||||
*/
|
||||
export const authorization = {
|
||||
_getHash(req) {
|
||||
const msg = RLP.encode(authorizationRequest.decode(req));
|
||||
return keccak_256(concatBytes(new Uint8Array([0x05]), msg));
|
||||
},
|
||||
sign(req, privateKey) {
|
||||
astr(privateKey);
|
||||
const sig = sign(this._getHash(req), ethHex.decode(privateKey));
|
||||
return { ...req, r: sig.r, s: sig.s, yParity: sig.recovery };
|
||||
},
|
||||
getAuthority(item) {
|
||||
const { r, s, yParity, ...req } = item;
|
||||
const hash = this._getHash(req);
|
||||
const sig = initSig({ r, s }, yParity);
|
||||
const point = sig.recoverPublicKey(hash);
|
||||
return addr.fromPublicKey(point.toHex(false));
|
||||
},
|
||||
};
|
||||
// Transaction-related utils.
|
||||
// 4 fields are required. Others are pre-filled with default values.
|
||||
const TX_DEFAULTS = {
|
||||
accessList: [], // needs to be .slice()-d to create new reference
|
||||
authorizationList: [],
|
||||
chainId: BigInt(1), // mainnet
|
||||
data: '',
|
||||
gasLimit: BigInt(21000), // TODO: investigate if limit is smaller in eip4844 txs
|
||||
maxPriorityFeePerGas: (BigInt(1) * amounts.GWEI), // Reduce fingerprinting by using standard, popular value
|
||||
type: 'eip1559',
|
||||
};
|
||||
// Changes:
|
||||
// - legacy: instead of hardfork now accepts additional param chainId
|
||||
// if chainId is present, we enable relay protection
|
||||
// This removes hardfork param and simplifies replay protection logic
|
||||
// - tx parametrized over type: you cannot access fields from different tx version
|
||||
// - legacy: 'v' param is hidden in coders. Transaction operates in terms chainId and yParity.
|
||||
// TODO: tx is kinda immutable, but user can change .raw values before signing
|
||||
// need to think about re-validation?
|
||||
export class Transaction {
|
||||
// Doesn't force any defaults, catches if fields incompatible with type
|
||||
constructor(type, raw, strict = true, allowSignatureFields = true) {
|
||||
this.type = type;
|
||||
this.raw = raw;
|
||||
validateFields(type, raw, strict, allowSignatureFields);
|
||||
this.isSigned = typeof raw.r === 'bigint' && typeof raw.s === 'bigint';
|
||||
}
|
||||
static prepare(data, strict = true) {
|
||||
const type = (data.type !== undefined ? data.type : TX_DEFAULTS.type);
|
||||
if (!TxVersions.hasOwnProperty(type))
|
||||
throw new Error(`wrong transaction type=${type}`);
|
||||
const coder = TxVersions[type];
|
||||
const fields = new Set(coder.fields);
|
||||
// Copy default fields, but only if the field is present on the tx type.
|
||||
const raw = { type };
|
||||
for (const f in TX_DEFAULTS) {
|
||||
if (f !== 'type' && fields.has(f)) {
|
||||
raw[f] = TX_DEFAULTS[f];
|
||||
if (['accessList', 'authorizationList'].includes(f))
|
||||
raw[f] = cloneDeep(raw[f]);
|
||||
}
|
||||
}
|
||||
// Copy all fields, so we can validate unexpected ones.
|
||||
return new Transaction(type, sortRawData(Object.assign(raw, data)), strict, false);
|
||||
}
|
||||
/**
|
||||
* Creates transaction which sends whole account balance. Does two things:
|
||||
* 1. `amount = accountBalance - maxFeePerGas * gasLimit`
|
||||
* 2. `maxPriorityFeePerGas = maxFeePerGas`
|
||||
*
|
||||
* Every eth block sets a fee for all its transactions, called base fee.
|
||||
* maxFeePerGas indicates how much gas user is able to spend in the worst case.
|
||||
* If the block's base fee is 5 gwei, while user is able to spend 10 gwei in maxFeePerGas,
|
||||
* the transaction would only consume 5 gwei. That means, base fee is unknown
|
||||
* before the transaction is included in a block.
|
||||
*
|
||||
* By setting priorityFee to maxFee, we make the process deterministic:
|
||||
* `maxFee = 10, maxPriority = 10, baseFee = 5` would always spend 10 gwei.
|
||||
* In the end, the balance would become 0.
|
||||
*
|
||||
* WARNING: using the method would decrease privacy of a transfer, because
|
||||
* payments for services have specific amounts, and not *the whole amount*.
|
||||
* @param accountBalance - account balance in wei
|
||||
* @param burnRemaining - send unspent fee to miners. When false, some "small amount" would remain
|
||||
* @returns new transaction with adjusted amounts
|
||||
*/
|
||||
setWholeAmount(accountBalance, burnRemaining = true) {
|
||||
const _0n = BigInt(0);
|
||||
if (typeof accountBalance !== 'bigint' || accountBalance <= _0n)
|
||||
throw new Error('account balance must be bigger than 0');
|
||||
const fee = this.fee;
|
||||
const amountToSend = accountBalance - fee;
|
||||
if (amountToSend <= _0n)
|
||||
throw new Error('account balance must be bigger than fee of ' + fee);
|
||||
const raw = { ...this.raw, value: amountToSend };
|
||||
if (!['legacy', 'eip2930'].includes(this.type) && burnRemaining) {
|
||||
const r = raw;
|
||||
r.maxPriorityFeePerGas = r.maxFeePerGas;
|
||||
}
|
||||
return new Transaction(this.type, raw);
|
||||
}
|
||||
static fromRawBytes(bytes, strict = false) {
|
||||
const raw = RawTx.decode(bytes);
|
||||
return new Transaction(raw.type, raw.data, strict);
|
||||
}
|
||||
static fromHex(hex, strict = false) {
|
||||
return Transaction.fromRawBytes(ethHexNoLeadingZero.decode(hex), strict);
|
||||
}
|
||||
assertIsSigned() {
|
||||
if (!this.isSigned)
|
||||
throw new Error('expected signed transaction');
|
||||
}
|
||||
/**
|
||||
* Converts transaction to RLP.
|
||||
* @param includeSignature whether to include signature
|
||||
*/
|
||||
toRawBytes(includeSignature = this.isSigned) {
|
||||
// cloneDeep is not necessary here
|
||||
let data = Object.assign({}, this.raw);
|
||||
if (includeSignature) {
|
||||
this.assertIsSigned();
|
||||
}
|
||||
else {
|
||||
removeSig(data);
|
||||
}
|
||||
return RawTx.encode({ type: this.type, data }); // TODO: remove any
|
||||
}
|
||||
/**
|
||||
* Converts transaction to hex.
|
||||
* @param includeSignature whether to include signature
|
||||
*/
|
||||
toHex(includeSignature = this.isSigned) {
|
||||
return ethHex.encode(this.toRawBytes(includeSignature));
|
||||
}
|
||||
/** Calculates keccak-256 hash of signed transaction. Used in block explorers. */
|
||||
get hash() {
|
||||
this.assertIsSigned();
|
||||
return bytesToHex(this.calcHash(true));
|
||||
}
|
||||
/** Returns sender's address. */
|
||||
get sender() {
|
||||
return this.recoverSender().address;
|
||||
}
|
||||
/**
|
||||
* For legacy transactions, but can be used with libraries when yParity presented as v.
|
||||
*/
|
||||
get v() {
|
||||
return decodeLegacyV(this.raw);
|
||||
}
|
||||
calcHash(includeSignature) {
|
||||
return keccak_256(this.toRawBytes(includeSignature));
|
||||
}
|
||||
/** Calculates MAXIMUM fee in wei that could be spent. */
|
||||
get fee() {
|
||||
const { type, raw } = this;
|
||||
// Fee calculation is not exact, real fee can be smaller
|
||||
let gasFee;
|
||||
if (type === 'legacy' || type === 'eip2930') {
|
||||
// Because TypeScript is not smart enough to narrow down types here :(
|
||||
const r = raw;
|
||||
gasFee = r.gasPrice;
|
||||
}
|
||||
else {
|
||||
const r = raw;
|
||||
// maxFeePerGas is absolute limit, you never pay more than that
|
||||
// maxFeePerGas = baseFeePerGas[*2] + maxPriorityFeePerGas
|
||||
gasFee = r.maxFeePerGas;
|
||||
}
|
||||
// TODO: how to calculate 4844 fee?
|
||||
return raw.gasLimit * gasFee;
|
||||
}
|
||||
clone() {
|
||||
return new Transaction(this.type, cloneDeep(this.raw));
|
||||
}
|
||||
verifySignature() {
|
||||
this.assertIsSigned();
|
||||
const { r, s } = this.raw;
|
||||
return verify({ r: r, s: s }, this.calcHash(false), hexToBytes(this.recoverSender().publicKey));
|
||||
}
|
||||
removeSignature() {
|
||||
return new Transaction(this.type, removeSig(cloneDeep(this.raw)));
|
||||
}
|
||||
/**
|
||||
* Signs transaction with a private key.
|
||||
* @param privateKey key in hex or Uint8Array format
|
||||
* @param opts extraEntropy will increase security of sig by mixing rfc6979 randomness
|
||||
* @returns new "same" transaction, but signed
|
||||
*/
|
||||
signBy(privateKey, extraEntropy = true) {
|
||||
if (this.isSigned)
|
||||
throw new Error('expected unsigned transaction');
|
||||
const priv = isBytes(privateKey) ? privateKey : hexToBytes(strip0x(privateKey));
|
||||
const hash = this.calcHash(false);
|
||||
const { r, s, recovery } = sign(hash, priv, extraEntropy);
|
||||
const sraw = Object.assign(cloneDeep(this.raw), { r, s, yParity: recovery });
|
||||
// The copied result is validated in non-strict way, strict is only for user input.
|
||||
return new Transaction(this.type, sraw, false);
|
||||
}
|
||||
/** Calculates public key and address from signed transaction's signature. */
|
||||
recoverSender() {
|
||||
this.assertIsSigned();
|
||||
const { r, s, yParity } = this.raw;
|
||||
const sig = initSig({ r: r, s: s }, yParity);
|
||||
// Will crash on 'chainstart' hardfork
|
||||
if (sig.hasHighS())
|
||||
throw new Error('invalid s');
|
||||
const point = sig.recoverPublicKey(this.calcHash(false));
|
||||
return { publicKey: point.toHex(true), address: addr.fromPublicKey(point.toHex(false)) };
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/index.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/index.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
41
dev/env/node_modules/micro-eth-signer/esm/kzg.d.ts
generated
vendored
Executable file
41
dev/env/node_modules/micro-eth-signer/esm/kzg.d.ts
generated
vendored
Executable file
@@ -0,0 +1,41 @@
|
||||
type Scalar = string | bigint;
|
||||
type Blob = string | string[] | bigint[];
|
||||
export type SetupData = {
|
||||
g1_lagrange: string[];
|
||||
g2_monomial: string[];
|
||||
};
|
||||
/**
|
||||
* KZG from [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844).
|
||||
* @example
|
||||
* const kzg = new KZG(trustedSetupData);
|
||||
*/
|
||||
export declare class KZG {
|
||||
private readonly POLY_NUM;
|
||||
private readonly G1LB;
|
||||
private readonly G2M;
|
||||
private readonly ROOTS_OF_UNITY;
|
||||
private readonly FIAT_SHAMIR_PROTOCOL_DOMAIN;
|
||||
private readonly RANDOM_CHALLENGE_KZG_BATCH_DOMAIN;
|
||||
private readonly POLY_NUM_BYTES;
|
||||
constructor(setup: SetupData & {
|
||||
encoding?: 'fast_v1';
|
||||
});
|
||||
private parseG1;
|
||||
private parseG1Unchecked;
|
||||
private parseG2;
|
||||
private parseG2Unchecked;
|
||||
private parseBlob;
|
||||
private invSafe;
|
||||
private G1msm;
|
||||
private computeChallenge;
|
||||
private evalPoly;
|
||||
computeProof(blob: Blob, z: bigint | string): [string, string];
|
||||
verifyProof(commitment: string, z: Scalar, y: Scalar, proof: string): boolean;
|
||||
private verifyProofBatch;
|
||||
blobToKzgCommitment(blob: Blob): string;
|
||||
computeBlobProof(blob: Blob, commitment: string): string;
|
||||
verifyBlobProof(blob: Blob, commitment: string, proof: string): boolean;
|
||||
verifyBlobProofBatch(blobs: string[], commitments: string[], proofs: string[]): boolean;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=kzg.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/kzg.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/kzg.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"kzg.d.ts","sourceRoot":"","sources":["../src/kzg.ts"],"names":[],"mappings":"AAqCA,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAC9B,KAAK,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;AAiEzC,MAAM,MAAM,SAAS,GAAG;IAEtB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAW;IAE1C,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAmC;IAC/E,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAmC;IACrF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAa;gBAEhC,KAAK,EAAE,SAAS,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE;IAkBvD,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,OAAO;IAGf,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,KAAK;IAYb,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,QAAQ;IAiBhB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAoC9D,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAc7E,OAAO,CAAC,gBAAgB;IA8BxB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAGvC,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAMxD,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAWvE,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO;CAqBxF"}
|
||||
334
dev/env/node_modules/micro-eth-signer/esm/kzg.js
generated
vendored
Executable file
334
dev/env/node_modules/micro-eth-signer/esm/kzg.js
generated
vendored
Executable file
@@ -0,0 +1,334 @@
|
||||
import { bitLen, bytesToNumberBE, numberToBytesBE } from '@noble/curves/abstract/utils';
|
||||
import { bls12_381 as bls } from '@noble/curves/bls12-381';
|
||||
import { sha256 } from '@noble/hashes/sha256';
|
||||
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
||||
import { add0x, hexToNumber, strip0x } from "./utils.js";
|
||||
/*
|
||||
KZG for [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844).
|
||||
|
||||
Docs:
|
||||
- https://github.com/ethereum/c-kzg-4844
|
||||
- https://github.com/ethereum/consensus-specs/blob/dev/specs/deneb/polynomial-commitments.md
|
||||
|
||||
TODO(high-level):
|
||||
- data converted into blob by prepending 0x00 prefix on each chunk and ends with 0x80 terminator
|
||||
- Unsure how generic is this
|
||||
- There are up to 6 blob per tx
|
||||
- Terminator only added to the last blob
|
||||
- sidecar: {blob, commitment, proof}
|
||||
- Calculate versionedHash from commitment, which is included inside of tx
|
||||
- if 'sidecars' inside of tx enabled:
|
||||
- envelope turns into 'wrapper'
|
||||
- rlp([tx, blobs, commitments, proofs])
|
||||
- this means there are two eip4844 txs: with sidecars and without
|
||||
|
||||
TODO(EIP7594):
|
||||
https://eips.ethereum.org/EIPS/eip-7594
|
||||
compute_cells_and_kzg_proofs(cells, proofs, blob);
|
||||
recover_cells_and_kzg_proofs(recovered_cells, recovered_proofs, cell_indices, cells, num_cells);
|
||||
verify_cell_kzg_proof_batch(commitments_bytes, cell_indices, cells, proofs_bytes, num_cells);
|
||||
*/
|
||||
const { Fr, Fp12 } = bls.fields;
|
||||
const G1 = bls.G1.ProjectivePoint;
|
||||
const G2 = bls.G2.ProjectivePoint;
|
||||
const BLOB_REGEX = /.{1,64}/g; // TODO: is this valid?
|
||||
function parseScalar(s) {
|
||||
if (typeof s === 'string') {
|
||||
s = strip0x(s);
|
||||
if (s.length !== 2 * Fr.BYTES)
|
||||
throw new Error('parseScalar: wrong format');
|
||||
s = BigInt(`0x${s}`);
|
||||
}
|
||||
if (!Fr.isValid(s))
|
||||
throw new Error('parseScalar: invalid field element');
|
||||
return s;
|
||||
}
|
||||
function formatScalar(n) {
|
||||
return add0x(bytesToHex(numberToBytesBE(n, Fr.BYTES)));
|
||||
}
|
||||
function isPowerOfTwo(x) {
|
||||
return (x & (x - 1)) === 0 && x !== 0;
|
||||
}
|
||||
function reverseBits(n, bits) {
|
||||
let reversed = 0;
|
||||
for (let i = 0; i < bits; i++, n >>>= 1)
|
||||
reversed = (reversed << 1) | (n & 1);
|
||||
return reversed;
|
||||
}
|
||||
// FFTish stuff, reverses bit in index
|
||||
function bitReversalPermutation(values) {
|
||||
const n = values.length;
|
||||
if (n < 2 || !isPowerOfTwo(n))
|
||||
throw new Error(`n must be a power of 2 and greater than 1. Got ${n}`);
|
||||
const bits = bitLen(BigInt(n)) - 1;
|
||||
const res = new Array(n);
|
||||
for (let i = 0; i < n; i++)
|
||||
res[reverseBits(i, bits)] = values[i];
|
||||
return res;
|
||||
}
|
||||
function computeRootsOfUnity(count) {
|
||||
if (count < 2)
|
||||
throw new Error('expected at least two roots');
|
||||
const PRIMITIVE_ROOT_OF_UNITY = 7;
|
||||
const order = BigInt(Math.log2(count));
|
||||
const power = (Fr.ORDER - BigInt(1)) / BigInt(2) ** order;
|
||||
const ROOT = Fr.pow(BigInt(PRIMITIVE_ROOT_OF_UNITY), power);
|
||||
const roots = [Fr.ONE, ROOT];
|
||||
for (let i = 2; i <= count; i++) {
|
||||
roots[i] = Fr.mul(roots[i - 1], ROOT);
|
||||
if (Fr.eql(roots[i], Fr.ONE))
|
||||
break;
|
||||
}
|
||||
if (!Fr.eql(roots[roots.length - 1], Fr.ONE))
|
||||
throw new Error('last root should be 1');
|
||||
roots.pop();
|
||||
if (roots.length !== count)
|
||||
throw new Error('invalid amount of roots');
|
||||
return bitReversalPermutation(roots);
|
||||
}
|
||||
function pairingVerify(a1, a2, b1, b2) {
|
||||
// Filter-out points at infinity, because pairingBatch will throw an error
|
||||
const pairs = [
|
||||
{ g1: a1.negate(), g2: a2 },
|
||||
{ g1: b1, g2: b2 },
|
||||
].filter(({ g1, g2 }) => !G1.ZERO.equals(g1) && !G2.ZERO.equals(g2));
|
||||
const f = bls.pairingBatch(pairs, true);
|
||||
return Fp12.eql(f, Fp12.ONE);
|
||||
}
|
||||
/**
|
||||
* KZG from [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844).
|
||||
* @example
|
||||
* const kzg = new KZG(trustedSetupData);
|
||||
*/
|
||||
export class KZG {
|
||||
constructor(setup) {
|
||||
// Should they be configurable?
|
||||
this.FIAT_SHAMIR_PROTOCOL_DOMAIN = utf8ToBytes('FSBLOBVERIFY_V1_');
|
||||
this.RANDOM_CHALLENGE_KZG_BATCH_DOMAIN = utf8ToBytes('RCKZGBATCH___V1_');
|
||||
if (setup == null || typeof setup !== 'object')
|
||||
throw new Error('expected valid setup data');
|
||||
if (!Array.isArray(setup.g1_lagrange) || !Array.isArray(setup.g2_monomial))
|
||||
throw new Error('expected valid setup data');
|
||||
// The slowest part
|
||||
let fastSetup = false;
|
||||
if ('encoding' in setup) {
|
||||
fastSetup = setup.encoding === 'fast_v1';
|
||||
if (!fastSetup)
|
||||
throw new Error('unknown encoding ' + setup.encoding);
|
||||
}
|
||||
const G1L = setup.g1_lagrange.map(fastSetup ? this.parseG1Unchecked : this.parseG1);
|
||||
this.POLY_NUM = G1L.length;
|
||||
this.G2M = setup.g2_monomial.map(fastSetup ? this.parseG2Unchecked : this.parseG2);
|
||||
this.G1LB = bitReversalPermutation(G1L);
|
||||
this.ROOTS_OF_UNITY = computeRootsOfUnity(this.POLY_NUM);
|
||||
this.POLY_NUM_BYTES = numberToBytesBE(this.POLY_NUM, 8);
|
||||
}
|
||||
// Internal
|
||||
parseG1(p) {
|
||||
if (typeof p === 'string')
|
||||
p = G1.fromHex(strip0x(p));
|
||||
return p;
|
||||
}
|
||||
parseG1Unchecked(p) {
|
||||
if (typeof p !== 'string')
|
||||
throw new Error('string expected');
|
||||
const [x, y] = p.split(' ').map(hexToNumber);
|
||||
return G1.fromAffine({ x, y });
|
||||
}
|
||||
parseG2(p) {
|
||||
return G2.fromHex(strip0x(p));
|
||||
}
|
||||
parseG2Unchecked(p) {
|
||||
const xy = strip0x(p)
|
||||
.split(' ')
|
||||
.map((c) => c.split(',').map((c) => BigInt('0x' + c)));
|
||||
const x = bls.fields.Fp2.fromBigTuple(xy[0]);
|
||||
const y = bls.fields.Fp2.fromBigTuple(xy[1]);
|
||||
return G2.fromAffine({ x, y });
|
||||
}
|
||||
parseBlob(blob) {
|
||||
if (typeof blob === 'string') {
|
||||
blob = strip0x(blob);
|
||||
if (blob.length !== this.POLY_NUM * Fr.BYTES * 2)
|
||||
throw new Error('Wrong blob length');
|
||||
const m = blob.match(BLOB_REGEX);
|
||||
if (!m)
|
||||
throw new Error('Wrong blob');
|
||||
blob = m;
|
||||
}
|
||||
return blob.map(parseScalar);
|
||||
}
|
||||
invSafe(inverses) {
|
||||
inverses = Fr.invertBatch(inverses);
|
||||
for (const i of inverses)
|
||||
if (i === undefined)
|
||||
throw new Error('invSafe: division by zero');
|
||||
return inverses;
|
||||
}
|
||||
G1msm(points, scalars) {
|
||||
// Filters zero scalars, non-const time, but improves computeProof up to x93 for empty blobs
|
||||
const _points = [];
|
||||
const _scalars = [];
|
||||
for (let i = 0; i < scalars.length; i++) {
|
||||
const s = scalars[i];
|
||||
if (Fr.is0(s))
|
||||
continue;
|
||||
_points.push(points[i]);
|
||||
_scalars.push(s);
|
||||
}
|
||||
return G1.msm(_points, _scalars);
|
||||
}
|
||||
computeChallenge(blob, commitment) {
|
||||
const h = sha256
|
||||
.create()
|
||||
.update(this.FIAT_SHAMIR_PROTOCOL_DOMAIN)
|
||||
.update(numberToBytesBE(0, 8))
|
||||
.update(this.POLY_NUM_BYTES);
|
||||
for (const b of blob)
|
||||
h.update(numberToBytesBE(b, Fr.BYTES));
|
||||
h.update(commitment.toRawBytes(true));
|
||||
const res = Fr.create(bytesToNumberBE(h.digest()));
|
||||
h.destroy();
|
||||
return res;
|
||||
}
|
||||
// Evaluate polynominal at the point x
|
||||
evalPoly(poly, x) {
|
||||
if (poly.length !== this.POLY_NUM)
|
||||
throw new Error('The polynomial length is incorrect');
|
||||
const batch = [];
|
||||
for (let i = 0; i < this.POLY_NUM; i++) {
|
||||
// This enforces that we don't try inverse of zero here
|
||||
if (Fr.eql(x, this.ROOTS_OF_UNITY[i]))
|
||||
return poly[i];
|
||||
batch.push(Fr.sub(x, this.ROOTS_OF_UNITY[i]));
|
||||
}
|
||||
const inverses = this.invSafe(batch);
|
||||
let res = Fr.ZERO;
|
||||
for (let i = 0; i < this.POLY_NUM; i++)
|
||||
res = Fr.add(res, Fr.mul(Fr.mul(inverses[i], this.ROOTS_OF_UNITY[i]), poly[i]));
|
||||
res = Fr.div(res, Fr.create(BigInt(this.POLY_NUM)));
|
||||
res = Fr.mul(res, Fr.sub(Fr.pow(x, BigInt(this.POLY_NUM)), Fr.ONE));
|
||||
return res;
|
||||
}
|
||||
// Basic
|
||||
computeProof(blob, z) {
|
||||
z = parseScalar(z);
|
||||
blob = this.parseBlob(blob);
|
||||
const y = this.evalPoly(blob, z);
|
||||
const batch = [];
|
||||
let rootOfUnityPos;
|
||||
const poly = new Array(this.POLY_NUM).fill(Fr.ZERO);
|
||||
for (let i = 0; i < this.POLY_NUM; i++) {
|
||||
if (Fr.eql(z, this.ROOTS_OF_UNITY[i])) {
|
||||
rootOfUnityPos = i;
|
||||
batch.push(Fr.ONE);
|
||||
continue;
|
||||
}
|
||||
poly[i] = Fr.sub(blob[i], y);
|
||||
batch.push(Fr.sub(this.ROOTS_OF_UNITY[i], z));
|
||||
}
|
||||
const inverses = this.invSafe(batch);
|
||||
for (let i = 0; i < this.POLY_NUM; i++)
|
||||
poly[i] = Fr.mul(poly[i], inverses[i]);
|
||||
if (rootOfUnityPos !== undefined) {
|
||||
poly[rootOfUnityPos] = Fr.ZERO;
|
||||
for (let i = 0; i < this.POLY_NUM; i++) {
|
||||
if (i === rootOfUnityPos)
|
||||
continue;
|
||||
batch[i] = Fr.mul(Fr.sub(z, this.ROOTS_OF_UNITY[i]), z);
|
||||
}
|
||||
const inverses = this.invSafe(batch);
|
||||
for (let i = 0; i < this.POLY_NUM; i++) {
|
||||
if (i === rootOfUnityPos)
|
||||
continue;
|
||||
poly[rootOfUnityPos] = Fr.add(poly[rootOfUnityPos], Fr.mul(Fr.mul(Fr.sub(blob[i], y), this.ROOTS_OF_UNITY[i]), inverses[i]));
|
||||
}
|
||||
}
|
||||
const proof = add0x(this.G1msm(this.G1LB, poly).toHex(true));
|
||||
return [proof, formatScalar(y)];
|
||||
}
|
||||
verifyProof(commitment, z, y, proof) {
|
||||
try {
|
||||
z = parseScalar(z);
|
||||
y = parseScalar(y);
|
||||
const g2x = Fr.is0(z) ? G2.ZERO : G2.BASE.multiply(z);
|
||||
const g1y = Fr.is0(y) ? G1.ZERO : G1.BASE.multiply(y);
|
||||
const XminusZ = this.G2M[1].subtract(g2x);
|
||||
const PminusY = this.parseG1(commitment).subtract(g1y);
|
||||
return pairingVerify(PminusY, G2.BASE, this.parseG1(proof), XminusZ);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// There are no test vectors for this
|
||||
verifyProofBatch(commitments, zs, ys, proofs) {
|
||||
const n = commitments.length;
|
||||
const p = proofs.map((i) => this.parseG1(i));
|
||||
const h = sha256
|
||||
.create()
|
||||
.update(this.RANDOM_CHALLENGE_KZG_BATCH_DOMAIN)
|
||||
.update(this.POLY_NUM_BYTES)
|
||||
.update(numberToBytesBE(n, 8));
|
||||
for (let i = 0; i < n; i++) {
|
||||
h.update(commitments[i].toRawBytes(true));
|
||||
h.update(Fr.toBytes(zs[i]));
|
||||
h.update(Fr.toBytes(ys[i]));
|
||||
h.update(p[i].toRawBytes(true));
|
||||
}
|
||||
const r = Fr.create(bytesToNumberBE(h.digest()));
|
||||
h.destroy();
|
||||
const rPowers = [];
|
||||
if (n !== 0) {
|
||||
rPowers.push(Fr.ONE);
|
||||
for (let i = 1; i < n; i++)
|
||||
rPowers[i] = Fr.mul(rPowers[i - 1], r);
|
||||
}
|
||||
const proofPowers = this.G1msm(p, rPowers);
|
||||
const CminusY = commitments.map((c, i) => c.subtract(Fr.is0(ys[i]) ? G1.ZERO : G1.BASE.multiply(ys[i])));
|
||||
const RtimesZ = rPowers.map((p, i) => Fr.mul(p, zs[i]));
|
||||
const rhs = this.G1msm(p.concat(CminusY), RtimesZ.concat(rPowers));
|
||||
return pairingVerify(proofPowers, this.G2M[1], rhs, G2.BASE);
|
||||
}
|
||||
// Blobs
|
||||
blobToKzgCommitment(blob) {
|
||||
return add0x(this.G1msm(this.G1LB, this.parseBlob(blob)).toHex(true));
|
||||
}
|
||||
computeBlobProof(blob, commitment) {
|
||||
blob = this.parseBlob(blob);
|
||||
const challenge = this.computeChallenge(blob, G1.fromHex(strip0x(commitment)));
|
||||
const [proof, _] = this.computeProof(blob, challenge);
|
||||
return proof;
|
||||
}
|
||||
verifyBlobProof(blob, commitment, proof) {
|
||||
try {
|
||||
blob = this.parseBlob(blob);
|
||||
const c = G1.fromHex(strip0x(commitment));
|
||||
const challenge = this.computeChallenge(blob, c);
|
||||
const y = this.evalPoly(blob, challenge);
|
||||
return this.verifyProof(commitment, challenge, y, proof);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
verifyBlobProofBatch(blobs, commitments, proofs) {
|
||||
if (!Array.isArray(blobs) || !Array.isArray(commitments) || !Array.isArray(proofs))
|
||||
throw new Error('invalid arguments');
|
||||
if (blobs.length !== commitments.length || blobs.length !== proofs.length)
|
||||
return false;
|
||||
if (blobs.length === 1)
|
||||
return this.verifyBlobProof(blobs[0], commitments[0], proofs[0]);
|
||||
try {
|
||||
const b = blobs.map((i) => this.parseBlob(i));
|
||||
const c = commitments.map((i) => G1.fromHex(strip0x(i)));
|
||||
const challenges = b.map((b, i) => this.computeChallenge(b, c[i]));
|
||||
const ys = b.map((_, i) => this.evalPoly(b[i], challenges[i]));
|
||||
return this.verifyProofBatch(c, challenges, ys, proofs);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=kzg.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/kzg.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/kzg.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
246
dev/env/node_modules/micro-eth-signer/esm/net/archive.d.ts
generated
vendored
Executable file
246
dev/env/node_modules/micro-eth-signer/esm/net/archive.d.ts
generated
vendored
Executable file
@@ -0,0 +1,246 @@
|
||||
import { TxVersions, type AccessList } from '../tx.ts';
|
||||
import { type IWeb3Provider, type Web3CallArgs } from '../utils.ts';
|
||||
declare const CONTRACT_CAPABILITIES: Record<string, string>;
|
||||
export type BlockInfo = {
|
||||
baseFeePerGas: bigint;
|
||||
difficulty: bigint;
|
||||
extraData: string;
|
||||
gasLimit: bigint;
|
||||
gasUsed: bigint;
|
||||
hash: string;
|
||||
logsBloom: string;
|
||||
miner: string;
|
||||
mixHash: string;
|
||||
nonce: string;
|
||||
number: number;
|
||||
parentHash: string;
|
||||
receiptsRoot: string;
|
||||
sha3Uncles: string;
|
||||
size: number;
|
||||
stateRoot: string;
|
||||
timestamp: number;
|
||||
totalDifficulty?: bigint;
|
||||
transactions: string[];
|
||||
transactionsRoot: string;
|
||||
uncles: string[];
|
||||
};
|
||||
export type Action = {
|
||||
action: {
|
||||
from: string;
|
||||
callType: string;
|
||||
gas: bigint;
|
||||
input: string;
|
||||
to: string;
|
||||
value: bigint;
|
||||
};
|
||||
blockHash: string;
|
||||
blockNumber: number;
|
||||
result: {
|
||||
gasUsed: bigint;
|
||||
output: string;
|
||||
};
|
||||
subtraces: number;
|
||||
traceAddress: string[];
|
||||
transactionHash: string;
|
||||
transactionPosition: number;
|
||||
type: string;
|
||||
};
|
||||
export type Log = {
|
||||
address: string;
|
||||
topics: string[];
|
||||
data: string;
|
||||
blockNumber: number;
|
||||
transactionHash: string;
|
||||
transactionIndex: number;
|
||||
blockHash: string;
|
||||
logIndex: number;
|
||||
removed: boolean;
|
||||
};
|
||||
export type TxInfo = {
|
||||
blockHash: string;
|
||||
blockNumber: number;
|
||||
hash: string;
|
||||
accessList?: AccessList;
|
||||
transactionIndex: number;
|
||||
type: number;
|
||||
nonce: bigint;
|
||||
input: string;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
chainId: bigint;
|
||||
v: bigint;
|
||||
yParity?: string;
|
||||
gas: bigint;
|
||||
maxPriorityFeePerGas?: bigint;
|
||||
from: string;
|
||||
to: string;
|
||||
maxFeePerGas?: bigint;
|
||||
value: bigint;
|
||||
gasPrice: bigint;
|
||||
maxFeePerBlobGas?: bigint;
|
||||
blobVersionedHashes?: string[];
|
||||
};
|
||||
export type TxReceipt = {
|
||||
transactionHash: string;
|
||||
blockHash: string;
|
||||
blockNumber: number;
|
||||
logsBloom: string;
|
||||
gasUsed: bigint;
|
||||
contractAddress: string | null;
|
||||
cumulativeGasUsed: bigint;
|
||||
transactionIndex: number;
|
||||
from: string;
|
||||
to: string;
|
||||
type: number;
|
||||
effectiveGasPrice: bigint;
|
||||
logs: Log[];
|
||||
status: number;
|
||||
blobGasPrice?: bigint;
|
||||
blobGasUsed?: bigint;
|
||||
};
|
||||
export type Unspent = {
|
||||
symbol: 'ETH';
|
||||
decimals: number;
|
||||
balance: bigint;
|
||||
nonce: number;
|
||||
active: boolean;
|
||||
};
|
||||
type ERC20Token = {
|
||||
abi: 'ERC20';
|
||||
name?: string;
|
||||
symbol?: string;
|
||||
decimals?: number;
|
||||
totalSupply: bigint;
|
||||
};
|
||||
type ERC721Token = {
|
||||
abi: 'ERC721';
|
||||
name?: string;
|
||||
symbol?: string;
|
||||
totalSupply?: bigint;
|
||||
enumerable?: boolean;
|
||||
metadata?: boolean;
|
||||
};
|
||||
type ERC1155Token = {
|
||||
abi: 'ERC1155';
|
||||
};
|
||||
export type TokenInfo = {
|
||||
contract: string;
|
||||
} & (ERC20Token | ERC721Token | ERC1155Token);
|
||||
type TokenError = {
|
||||
contract: string;
|
||||
error: string;
|
||||
};
|
||||
type TokenBalanceSingle = Map<bigint, bigint>;
|
||||
export type TokenBalances = Record<string, TokenBalanceSingle | TokenError>;
|
||||
export type Topics = (string | null | (string | null)[])[];
|
||||
export type Transfer = {
|
||||
from: string;
|
||||
to?: string;
|
||||
value: bigint;
|
||||
};
|
||||
export type TokenTransfer = TokenInfo & {
|
||||
from: string;
|
||||
to: string;
|
||||
tokens: Map<bigint, bigint>;
|
||||
};
|
||||
export type TxTransfers = {
|
||||
hash: string;
|
||||
timestamp?: number;
|
||||
block?: number;
|
||||
transfers: Transfer[];
|
||||
tokenTransfers: TokenTransfer[];
|
||||
reverted: boolean;
|
||||
info: {
|
||||
type: keyof typeof TxVersions;
|
||||
info: TxInfo;
|
||||
receipt: TxReceipt;
|
||||
raw?: string;
|
||||
block: BlockInfo;
|
||||
actions: Action[];
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Callbacks are needed, because we want to call getTx / getBlock / getTokenInfo
|
||||
* requests as fast as possible, to reduce amount of sequential execution.
|
||||
* If we retrieve 10 pages of transactions, we can call per tx
|
||||
* callbacks for transaction from first page before all other pages fetched.
|
||||
*
|
||||
* Ensure caching: they can be called multiple times for same tx / block.
|
||||
*/
|
||||
export type Callbacks = {
|
||||
txCallback?: (txHash: string) => void;
|
||||
blockCallback?: (blockNum: number) => void;
|
||||
contractCallback?: (contrct: string) => void;
|
||||
};
|
||||
export type Pagination = {
|
||||
fromBlock?: number;
|
||||
toBlock?: number;
|
||||
};
|
||||
export type TraceOpts = Callbacks & Pagination & {
|
||||
perRequest?: number;
|
||||
limitTrace?: number;
|
||||
};
|
||||
export type LogOpts = Callbacks & (Pagination | {
|
||||
fromBlock: number;
|
||||
toBlock: number;
|
||||
limitLogs: number;
|
||||
});
|
||||
export type Balances = {
|
||||
balances: Record<string, bigint>;
|
||||
tokenBalances: Record<string, Record<string, bigint>>;
|
||||
};
|
||||
export type TxInfoOpts = Callbacks & {
|
||||
ignoreTxRebuildErrors?: boolean;
|
||||
};
|
||||
export type TxAllowances = Record<string, Record<string, bigint>>;
|
||||
export type JsonrpcInterface = {
|
||||
call: (method: string, ...args: any[]) => Promise<any>;
|
||||
};
|
||||
/**
|
||||
* Transaction-related code around Web3Provider.
|
||||
* High-level methods are `height`, `unspent`, `transfers`, `allowances` and `tokenBalances`.
|
||||
*
|
||||
* Low-level methods are `blockInfo`, `internalTransactions`, `ethLogs`, `tokenTransfers`, `wethTransfers`,
|
||||
* `tokenInfo` and `txInfo`.
|
||||
*/
|
||||
export declare class Web3Provider implements IWeb3Provider {
|
||||
private rpc;
|
||||
constructor(rpc: JsonrpcInterface);
|
||||
call(method: string, ...args: any[]): Promise<any>;
|
||||
ethCall(args: Web3CallArgs, tag?: string): Promise<any>;
|
||||
estimateGas(args: Web3CallArgs, tag?: string): Promise<bigint>;
|
||||
blockInfo(block: number): Promise<BlockInfo>;
|
||||
unspent(address: string): Promise<Unspent>;
|
||||
height(): Promise<number>;
|
||||
traceFilterSingle(address: string, opts?: TraceOpts): Promise<any>;
|
||||
internalTransactions(address: string, opts?: TraceOpts): Promise<any[]>;
|
||||
contractCapabilities(address: string, capabilities?: typeof CONTRACT_CAPABILITIES): Promise<{
|
||||
[k: string]: boolean;
|
||||
}>;
|
||||
ethLogsSingle(topics: Topics, opts: LogOpts): Promise<Log[]>;
|
||||
ethLogs(topics: Topics, opts?: LogOpts): Promise<Log[]>;
|
||||
tokenTransfers(address: string, opts?: LogOpts): Promise<[Log[], Log[]]>;
|
||||
wethTransfers(address: string, opts?: LogOpts): Promise<[Log[]]>;
|
||||
erc1155Transfers(address: string, opts?: LogOpts): Promise<[Log[], Log[], Log[], Log[]]>;
|
||||
txInfo(txHash: string, opts?: TxInfoOpts): Promise<{
|
||||
type: 'legacy' | 'eip2930' | 'eip1559' | 'eip4844' | 'eip7702';
|
||||
info: any;
|
||||
receipt: any;
|
||||
raw: string | undefined;
|
||||
}>;
|
||||
tokenInfo(contract: string): Promise<TokenInfo | TokenError>;
|
||||
private tokenBalanceSingle;
|
||||
tokenURI(token: TokenInfo | TokenError | string, tokenId: bigint): Promise<string | TokenError>;
|
||||
tokenBalances(address: string, tokens: string[], tokenIds?: Record<string, Set<bigint>>): Promise<TokenBalances>;
|
||||
private decodeTokenTransfer;
|
||||
transfers(address: string, opts?: TraceOpts & LogOpts): Promise<TxTransfers[]>;
|
||||
allowances(address: string, opts?: LogOpts): Promise<TxAllowances>;
|
||||
}
|
||||
/**
|
||||
* Calculates balances at specific point in time after tx.
|
||||
* Also, useful as a sanity check in case we've missed something.
|
||||
* Info from multiple addresses can be merged (sort everything first).
|
||||
*/
|
||||
export declare function calcTransfersDiff(transfers: TxTransfers[]): (TxTransfers & Balances)[];
|
||||
export {};
|
||||
//# sourceMappingURL=archive.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/archive.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/archive.d.ts.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
767
dev/env/node_modules/micro-eth-signer/esm/net/archive.js
generated
vendored
Executable file
767
dev/env/node_modules/micro-eth-signer/esm/net/archive.js
generated
vendored
Executable file
@@ -0,0 +1,767 @@
|
||||
import { ERC1155, ERC20, ERC721, WETH, createContract, events } from "../abi/index.js";
|
||||
import { Transaction } from "../index.js";
|
||||
import { TxVersions, legacySig } from "../tx.js";
|
||||
import { amounts, ethHex, hexToNumber } from "../utils.js";
|
||||
/*
|
||||
Methods to fetch list of transactions from any ETH node RPC.
|
||||
It should be easy. However, this is sparta^W ethereum, so, prepare to suffer.
|
||||
|
||||
The network is not directly called: `ArchiveNodeProvider#rpc` calls `Web3Provider`.
|
||||
|
||||
- There is no simple & fast API inside nodes, all external API create their own namespace for this
|
||||
- API is different between nodes: erigon uses streaming, other nodes use pagination
|
||||
- Recently, Erigon have been also adding pagination
|
||||
- For token transactions: download block headers, look at bloom filter, download affected blocks
|
||||
- There is a good `getLogs` API for contracts, but nothing for ETH transfers
|
||||
- `trace_filter` is slow: it not only finds the transaction, but also executes them
|
||||
- It's good that it allows to get internal transactions
|
||||
- The whole thing could be 10x simpler if there was an event in logs for ETH transfer
|
||||
- For most cases, we only need to see last transactions and know blocks of last txs, which is 20x faster
|
||||
- This creates a lot of requests to node (2 per tx, 1 per block, and some more depends on block range limits)
|
||||
|
||||
Recommended software:
|
||||
|
||||
- eth-nodes-for-rent are bad, because of their limits and timeouts
|
||||
- erigon nodes are fast, taking ~15 seconds per batch
|
||||
- reth has 100-block limit for trace_filter, requiring 190k requests just get transactions
|
||||
*/
|
||||
// Utils
|
||||
const ethNum = (n) => `0x${!n ? '0' : n.toString(16).replace(/^0+/, '')}`;
|
||||
const ERC_TRANSFER = events(ERC20).Transfer;
|
||||
const WETH_DEPOSIT = events(WETH).Deposit;
|
||||
const WETH_WITHDRAW = events(WETH).Withdrawal;
|
||||
const ERC721_TRANSFER = events(ERC721).Transfer;
|
||||
const ERC1155_SINGLE = events(ERC1155).TransferSingle;
|
||||
const ERC1155_BATCH = events(ERC1155).TransferBatch;
|
||||
const ERC165 = [
|
||||
// function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
{
|
||||
type: 'function',
|
||||
name: 'supportsInterface',
|
||||
inputs: [{ name: 'interfaceID', type: 'bytes4' }],
|
||||
outputs: [{ type: 'bool' }],
|
||||
},
|
||||
];
|
||||
const CONTRACT_CAPABILITIES = {
|
||||
erc165: '0x01ffc9a7',
|
||||
erc165_check: '0xffffffff',
|
||||
erc20: '0x36372b07',
|
||||
erc721: '0x80ac58cd',
|
||||
erc721_metadata: '0x5b5e139f',
|
||||
erc721_enumerable: '0x780e9d63',
|
||||
erc1155: '0xd9b67a26',
|
||||
erc1155_tokenreceiver: '0x4e2312e0',
|
||||
erc1155_metadata: '0x0e89341c',
|
||||
};
|
||||
function group(items, s) {
|
||||
let res = {};
|
||||
for (let i of items) {
|
||||
const key = typeof s === 'function' ? s(i) : i[s];
|
||||
if (!res[key])
|
||||
res[key] = [];
|
||||
res[key].push(i);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function fixBlock(block) {
|
||||
block.timestamp = Number(block.timestamp) * 1000;
|
||||
block.size = Number(block.size);
|
||||
if (block.number && block.number !== null)
|
||||
block.number = Number(block.number);
|
||||
for (const i of [
|
||||
'baseFeePerGas',
|
||||
'difficulty',
|
||||
'gasLimit',
|
||||
'gasUsed',
|
||||
'totalDifficulty',
|
||||
]) {
|
||||
if (block[i] && block[i] !== null)
|
||||
block[i] = BigInt(block[i]);
|
||||
}
|
||||
}
|
||||
function fixAction(action, opts = {}) {
|
||||
action.action.value = BigInt(action.action.value);
|
||||
action.action.gas = BigInt(action.action.gas);
|
||||
action.result.gasUsed = BigInt(action.result.gasUsed);
|
||||
if (opts.txCallback)
|
||||
opts.txCallback(action.transactionHash);
|
||||
if (opts.blockCallback)
|
||||
opts.blockCallback(action.blockNumber);
|
||||
}
|
||||
// Fixes type of network response inplace
|
||||
function fixLog(log, opts = {}) {
|
||||
log.blockNumber = Number(log.blockNumber);
|
||||
log.transactionIndex = Number(log.transactionIndex);
|
||||
log.logIndex = Number(log.logIndex);
|
||||
if (opts.txCallback)
|
||||
opts.txCallback(log.transactionHash);
|
||||
if (opts.blockCallback)
|
||||
opts.blockCallback(log.blockNumber);
|
||||
if (opts.contractCallback)
|
||||
opts.contractCallback(log.address);
|
||||
return log;
|
||||
}
|
||||
function fixTxInfo(info) {
|
||||
for (const i of ['blockNumber', 'type', 'transactionIndex'])
|
||||
info[i] = Number(info[i]);
|
||||
for (const i of [
|
||||
'nonce',
|
||||
'r',
|
||||
's',
|
||||
'chainId',
|
||||
'v',
|
||||
'gas',
|
||||
'maxPriorityFeePerGas',
|
||||
'maxFeePerGas',
|
||||
'value',
|
||||
'gasPrice',
|
||||
'maxFeePerBlobGas',
|
||||
]) {
|
||||
if (info[i] !== undefined && info[i] !== null)
|
||||
info[i] = BigInt(info[i]);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
function fixTxReceipt(receipt) {
|
||||
for (const i of ['blockNumber', 'type', 'transactionIndex', 'status'])
|
||||
receipt[i] = Number(receipt[i]);
|
||||
for (const i of [
|
||||
'gasUsed',
|
||||
'cumulativeGasUsed',
|
||||
'effectiveGasPrice',
|
||||
'blobGasPrice',
|
||||
'blobGasUsed',
|
||||
]) {
|
||||
if (receipt[i] !== undefined)
|
||||
receipt[i] = BigInt(receipt[i]);
|
||||
}
|
||||
for (const log of receipt.logs)
|
||||
fixLog(log);
|
||||
return receipt;
|
||||
}
|
||||
function validateCallbacks(opts) {
|
||||
for (const i of ['txCallback', 'blockCallback', 'contractCallback']) {
|
||||
if (opts[i] !== undefined && typeof opts[i] !== 'function')
|
||||
throw new Error(`validateCallbacks: ${i} should be function`);
|
||||
}
|
||||
}
|
||||
function validatePagination(opts) {
|
||||
for (const i of ['fromBlock', 'toBlock']) {
|
||||
if (opts[i] === undefined || Number.isSafeInteger(opts[i]))
|
||||
continue;
|
||||
throw new Error(`validatePagination: wrong field ${i}=${opts[i]}. Should be integer or undefined`);
|
||||
}
|
||||
}
|
||||
function validateTraceOpts(opts) {
|
||||
validatePagination(opts);
|
||||
for (const i of ['perRequest', 'limitTrace']) {
|
||||
if (opts[i] === undefined || Number.isSafeInteger(opts[i]))
|
||||
continue;
|
||||
throw new Error(`validateTraceOpts: wrong field ${i}=${opts[i]}. Should be integer or undefined`);
|
||||
}
|
||||
if (opts.limitTrace !== undefined) {
|
||||
if (opts.fromBlock === undefined || opts.toBlock === undefined)
|
||||
throw new Error('validateTraceOpts: fromBlock/toBlock required if limitTrace is present');
|
||||
}
|
||||
validateCallbacks(opts);
|
||||
}
|
||||
function validateLogOpts(opts) {
|
||||
validatePagination(opts);
|
||||
for (const i of ['limitLogs']) {
|
||||
if (opts[i] === undefined || Number.isSafeInteger(opts[i]))
|
||||
continue;
|
||||
throw new Error(`validateLogOpts: wrong field ${i}=${opts[i]}. Should be integer or undefined`);
|
||||
}
|
||||
if (opts.limitLogs !== undefined) {
|
||||
if (opts.fromBlock === undefined || opts.toBlock === undefined)
|
||||
throw new Error('validateLogOpts: fromBlock/toBlock required if limitLogs is present');
|
||||
}
|
||||
validateCallbacks(opts);
|
||||
}
|
||||
// Promise.all for objects, undefined if error
|
||||
async function wait(obj) {
|
||||
const keys = Object.keys(obj);
|
||||
const p = await Promise.allSettled(Object.values(obj));
|
||||
const res = p.map((r, i) => [keys[i], r.status === 'fulfilled' ? r.value : undefined]);
|
||||
return Object.fromEntries(res);
|
||||
}
|
||||
const isReverted = (e) => e instanceof Error && e.message.toLowerCase().includes('revert');
|
||||
/**
|
||||
* Transaction-related code around Web3Provider.
|
||||
* High-level methods are `height`, `unspent`, `transfers`, `allowances` and `tokenBalances`.
|
||||
*
|
||||
* Low-level methods are `blockInfo`, `internalTransactions`, `ethLogs`, `tokenTransfers`, `wethTransfers`,
|
||||
* `tokenInfo` and `txInfo`.
|
||||
*/
|
||||
export class Web3Provider {
|
||||
constructor(rpc) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
call(method, ...args) {
|
||||
return this.rpc.call(method, ...args);
|
||||
}
|
||||
ethCall(args, tag = 'latest') {
|
||||
return this.rpc.call('eth_call', args, tag);
|
||||
}
|
||||
async estimateGas(args, tag = 'latest') {
|
||||
return hexToNumber(await this.rpc.call('eth_estimateGas', args, tag));
|
||||
}
|
||||
// Timestamp is available only inside blocks
|
||||
async blockInfo(block) {
|
||||
const res = await this.call('eth_getBlockByNumber', ethNum(block), false);
|
||||
fixBlock(res);
|
||||
return res;
|
||||
}
|
||||
async unspent(address) {
|
||||
let [balance, nonce] = await Promise.all([
|
||||
this.call('eth_getBalance', address, 'latest'),
|
||||
this.call('eth_getTransactionCount', address, 'latest'),
|
||||
]);
|
||||
balance = BigInt(balance);
|
||||
nonce = BigInt(nonce);
|
||||
return {
|
||||
symbol: 'ETH',
|
||||
decimals: amounts.ETH_PRECISION,
|
||||
balance,
|
||||
nonce,
|
||||
// Note: account can be active even if nonce!==0!
|
||||
active: balance > 0 || nonce !== 0,
|
||||
};
|
||||
}
|
||||
async height() {
|
||||
return Number.parseInt(await this.call('eth_blockNumber'));
|
||||
}
|
||||
async traceFilterSingle(address, opts = {}) {
|
||||
const res = await this.call('trace_filter', {
|
||||
fromBlock: ethNum(opts.fromBlock),
|
||||
toBlock: ethNum(opts.toBlock),
|
||||
toAddress: [address],
|
||||
fromAddress: [address],
|
||||
});
|
||||
for (const action of res)
|
||||
fixAction(action, opts);
|
||||
return res;
|
||||
}
|
||||
async internalTransactions(address, opts = {}) {
|
||||
if (typeof address !== 'string')
|
||||
throw new Error('internalTransactions: wrong address');
|
||||
validateTraceOpts(opts);
|
||||
// For reth
|
||||
if (opts.limitTrace) {
|
||||
const promises = [];
|
||||
for (let i = opts.fromBlock; i <= opts.toBlock; i += opts.limitTrace)
|
||||
promises.push(this.traceFilterSingle(address, { fromBlock: i, toBlock: i + opts.limitTrace }));
|
||||
const out = [];
|
||||
for (const i of await Promise.all(promises))
|
||||
out.push(...i);
|
||||
return out;
|
||||
}
|
||||
let lastBlock = opts.fromBlock || 0;
|
||||
const perBlock = {};
|
||||
const out = [];
|
||||
for (;;) {
|
||||
const params = {
|
||||
fromBlock: ethNum(lastBlock),
|
||||
toAddress: [address],
|
||||
fromAddress: [address],
|
||||
after: perBlock[lastBlock] || 0, // we cannot just store after, since fromBlock changes to last block
|
||||
};
|
||||
if (opts.toBlock !== undefined)
|
||||
params.toBlock = ethNum(opts.toBlock);
|
||||
if (opts.perRequest !== undefined)
|
||||
params.count = opts.perRequest;
|
||||
const res = await this.call('trace_filter', params);
|
||||
if (!res.length)
|
||||
break;
|
||||
for (const action of res) {
|
||||
fixAction(action, opts);
|
||||
if (perBlock[action.blockNumber] === undefined)
|
||||
perBlock[action.blockNumber] = 0;
|
||||
perBlock[action.blockNumber]++;
|
||||
out.push(action);
|
||||
lastBlock = Math.max(lastBlock, action.blockNumber);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
async contractCapabilities(address, capabilities = {}) {
|
||||
const all = { ...CONTRACT_CAPABILITIES, ...capabilities };
|
||||
let c = createContract(ERC165, this, address);
|
||||
const keys = Object.keys(all);
|
||||
// TODO: what about revert?
|
||||
// if reverted -> all capabilities disabled
|
||||
try {
|
||||
const promises = await Promise.all(Object.values(all).map((i) => c.supportsInterface.call(ethHex.decode(i))));
|
||||
const res = Object.fromEntries(keys.map((k, i) => [k, promises[i]]));
|
||||
// if somehow there is same method, but it doesn't support erc165, then it is different method!
|
||||
// erc165_check if sailsafe when there is method that always returns true
|
||||
if (!res.erc165 || res.erc165_check)
|
||||
for (const k in res)
|
||||
res[k] = false;
|
||||
return res;
|
||||
}
|
||||
catch (e) {
|
||||
// If execution reverted: contract doesn't support ERC165
|
||||
if (isReverted(e))
|
||||
return Object.fromEntries(keys.map((k) => [k, false]));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async ethLogsSingle(topics, opts) {
|
||||
const req = { topics, fromBlock: ethNum(opts.fromBlock || 0) };
|
||||
if (opts.toBlock !== undefined)
|
||||
req.toBlock = ethNum(opts.toBlock);
|
||||
const res = await this.call('eth_getLogs', req);
|
||||
return res.map((i) => fixLog(i, opts));
|
||||
}
|
||||
async ethLogs(topics, opts = {}) {
|
||||
validateLogOpts(opts);
|
||||
const fromBlock = opts.fromBlock || 0;
|
||||
if (!('limitLogs' in opts))
|
||||
return this.ethLogsSingle(topics, opts);
|
||||
const promises = [];
|
||||
for (let i = fromBlock; i <= opts.toBlock; i += opts.limitLogs)
|
||||
promises.push(this.ethLogsSingle(topics, { fromBlock: i, toBlock: i + opts.limitLogs }));
|
||||
const out = [];
|
||||
for (const i of await Promise.all(promises))
|
||||
out.push(...i);
|
||||
return out;
|
||||
}
|
||||
// NOTE: this is very low-level methods that return parts used for .transfers method,
|
||||
// you will need to decode data yourself.
|
||||
async tokenTransfers(address, opts = {}) {
|
||||
if (typeof address !== 'string')
|
||||
throw new Error('tokenTransfers: wrong address');
|
||||
validateLogOpts(opts);
|
||||
// If we want incoming and outgoing token transfers we need to call both
|
||||
return await Promise.all([
|
||||
this.ethLogs(ERC_TRANSFER.topics({ from: address, to: null, value: null }), opts), // From
|
||||
this.ethLogs(ERC_TRANSFER.topics({ from: null, to: address, value: null }), opts), // To
|
||||
]);
|
||||
}
|
||||
async wethTransfers(address, opts = {}) {
|
||||
if (typeof address !== 'string')
|
||||
throw new Error('tokenTransfers: wrong address');
|
||||
validateLogOpts(opts);
|
||||
const depositTopic = WETH_DEPOSIT.topics({ dst: address, wad: null });
|
||||
const withdrawTopic = WETH_WITHDRAW.topics({ src: address, wad: null });
|
||||
// OR query
|
||||
return await Promise.all([
|
||||
this.ethLogs([[depositTopic[0], withdrawTopic[0]], depositTopic[1]], opts),
|
||||
]);
|
||||
}
|
||||
async erc1155Transfers(address, opts = {}) {
|
||||
if (typeof address !== 'string')
|
||||
throw new Error('tokenTransfers: wrong address');
|
||||
validateLogOpts(opts);
|
||||
return await Promise.all([
|
||||
// Single
|
||||
this.ethLogs(ERC1155_SINGLE.topics({ operator: null, from: address, to: null, id: null, value: null }), opts),
|
||||
this.ethLogs(ERC1155_SINGLE.topics({ operator: null, from: null, to: address, id: null, value: null }), opts),
|
||||
// Batch
|
||||
this.ethLogs(ERC1155_BATCH.topics({ operator: null, from: address, to: null, ids: null, values: null }), opts),
|
||||
this.ethLogs(ERC1155_BATCH.topics({ operator: null, from: null, to: address, ids: null, values: null }), opts),
|
||||
]);
|
||||
}
|
||||
async txInfo(txHash, opts = {}) {
|
||||
let [info, receipt] = await Promise.all([
|
||||
this.call('eth_getTransactionByHash', txHash),
|
||||
this.call('eth_getTransactionReceipt', txHash),
|
||||
]);
|
||||
info = fixTxInfo(info);
|
||||
receipt = fixTxReceipt(receipt);
|
||||
const type = Object.keys(TxVersions)[info.type];
|
||||
// This is not strictly neccessary, but allows to store tx info in very compact format and remove unneccessary fields
|
||||
// Also, there is additional validation that node returned actual with correct hash/sender and not corrupted stuff.
|
||||
let raw = undefined;
|
||||
try {
|
||||
const rawData = {
|
||||
nonce: info.nonce,
|
||||
gasLimit: info.gas,
|
||||
to: info.to === null ? '0x' : info.to,
|
||||
value: info.value,
|
||||
data: info.input,
|
||||
r: info.r,
|
||||
s: info.s,
|
||||
yParity: Number(info.v),
|
||||
chainId: info.chainId,
|
||||
};
|
||||
if (info.accessList)
|
||||
rawData.accessList = info.accessList;
|
||||
if (info.maxFeePerBlobGas)
|
||||
rawData.maxFeePerBlobGas = info.maxFeePerBlobGas;
|
||||
if (info.blobVersionedHashes)
|
||||
rawData.blobVersionedHashes = info.blobVersionedHashes;
|
||||
if (info.maxFeePerGas) {
|
||||
rawData.maxFeePerGas = info.maxFeePerGas;
|
||||
rawData.maxPriorityFeePerGas = info.maxPriorityFeePerGas;
|
||||
}
|
||||
else if (info.gasPrice)
|
||||
rawData.gasPrice = info.gasPrice;
|
||||
if (type === 'legacy')
|
||||
Object.assign(rawData, legacySig.encode({ v: info.v, r: info.r, s: info.s }));
|
||||
const tx = new Transaction(type, rawData, false, true);
|
||||
if (tx.recoverSender().address.toLowerCase() !== info.from.toLowerCase())
|
||||
throw new Error('txInfo: wrong sender');
|
||||
if (receipt.transactionHash !== `0x${tx.hash}`)
|
||||
throw new Error('txInfo: wrong hash');
|
||||
raw = tx.toHex();
|
||||
}
|
||||
catch (err) {
|
||||
// This can crash if something wrong with our parser or limits, so
|
||||
// we have option to make network code to work even if rebuilding is crashed
|
||||
if (!opts.ignoreTxRebuildErrors)
|
||||
throw err;
|
||||
}
|
||||
if (opts.blockCallback && info.blockNumber !== null)
|
||||
opts.blockCallback(info.blockNumber);
|
||||
return { type, info, receipt, raw };
|
||||
}
|
||||
async tokenInfo(contract) {
|
||||
const c = createContract(ERC20, this, contract);
|
||||
const t = await wait({
|
||||
code: this.call('eth_getCode', contract, 'latest'),
|
||||
capabilities: this.contractCapabilities(contract),
|
||||
// We call all stuff at same time to reduce latency (should be done in single req if batched)
|
||||
name: c.name.call(), // ERC-20 (optional), ERC-721 (metada)
|
||||
symbol: c.symbol.call(), // ERC-20 (optional), ERC-721 (metadata)
|
||||
decimals: c.decimals.call(), // ERC-20 (optional), ERC-721 (enumarable)
|
||||
totalSupply: c.totalSupply.call(), // ERC-20 (required), ERC-721
|
||||
});
|
||||
// No code, probably self-destructed
|
||||
if (t.code === '0x')
|
||||
return { contract, error: 'not contract or destructed' };
|
||||
if (t.capabilities && t.capabilities.erc1155) {
|
||||
// All metadata is inside URI per tokenId to outside network stuff (maybe ipfs), so nothing to do here.
|
||||
return { contract, abi: 'ERC1155' };
|
||||
}
|
||||
if (t.capabilities && t.capabilities.erc721) {
|
||||
const res = { contract, abi: 'ERC721' };
|
||||
if (t.capabilities.erc721_metadata) {
|
||||
if (t.name === undefined)
|
||||
return { contract, error: 'ERC721+Metadata without name' };
|
||||
if (t.symbol === undefined)
|
||||
return { contract, error: 'ERC721+Metadata without symbol' };
|
||||
Object.assign(res, { name: t.name, symbol: t.symbol, metadata: true });
|
||||
}
|
||||
if (t.capabilities.erc721_enumerable) {
|
||||
if (t.totalSupply === undefined)
|
||||
return { contract, error: 'ERC721+Enumerable without totalSupply' };
|
||||
Object.assign(res, { totalSupply: t.totalSupply, enumerable: true });
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (t.totalSupply === undefined)
|
||||
return { contract, error: 'not ERC20 token' }; // If there is no totalSupply, it is not ERC20!
|
||||
return {
|
||||
contract,
|
||||
abi: 'ERC20',
|
||||
name: t.name,
|
||||
symbol: t.symbol,
|
||||
totalSupply: t.totalSupply,
|
||||
decimals: t.decimals ? Number(t.decimals) : undefined,
|
||||
};
|
||||
}
|
||||
async tokenBalanceSingle(address, token, tokenIds) {
|
||||
if ('error' in token)
|
||||
return token;
|
||||
if (token.abi === 'ERC20') {
|
||||
const balance = await createContract(ERC20, this, token.contract).balanceOf.call(address);
|
||||
if (tokenIds && (tokenIds.size > 1 || Array.from(tokenIds)[0] !== 1n)) {
|
||||
return { contract: token.contract, error: 'unexpected tokenIds for ERC20' };
|
||||
}
|
||||
return new Map([[1n, balance]]);
|
||||
}
|
||||
else if (token.abi === 'ERC721') {
|
||||
const c = createContract(ERC721, this, token.contract);
|
||||
const balance = await c.balanceOf.call(address);
|
||||
if (!token.enumerable) {
|
||||
if (!tokenIds) {
|
||||
if (!balance)
|
||||
return new Map(); // no tokens owned by user
|
||||
return {
|
||||
contract: token.contract,
|
||||
error: 'erc721 contract not enumerable, but owner has ' + balance + ' tokens',
|
||||
};
|
||||
}
|
||||
// if we cannot enumerate, but has tokenIds, we can check if tokenIds still owned by account
|
||||
const ids = Array.from(tokenIds);
|
||||
const owners = await Promise.all(ids.map((i) => c.ownerOf.call(i)));
|
||||
return new Map(ids.map((i, j) => [i, owners[j].toLowerCase() === address.toLowerCase() ? 1n : 0n]));
|
||||
}
|
||||
// if we can fetch tokenIds: always do this
|
||||
const p = [];
|
||||
for (let i = 0; i < balance; i++)
|
||||
p.push(c.tokenOfOwnerByIndex.call({ owner: address, index: BigInt(i) }));
|
||||
tokenIds = new Set(await Promise.all(p));
|
||||
const ids = Array.from(tokenIds);
|
||||
return new Map(ids.map((i) => [i, 1n]));
|
||||
}
|
||||
else if (token.abi === 'ERC1155') {
|
||||
// This is pretty bad standard, because it doesn't allow enumeration of tokenIds for owner
|
||||
if (!tokenIds)
|
||||
return { contract: token.contract, error: 'cannot fetch erc1155 without tokenIds' };
|
||||
const c = createContract(ERC1155, this, token.contract);
|
||||
const ids = Array.from(tokenIds);
|
||||
const balances = await c.balanceOfBatch.call({ accounts: ids.map((_) => address), ids });
|
||||
const res = new Map(ids.map((i, j) => [i, balances[j]]));
|
||||
return res;
|
||||
}
|
||||
throw new Error('unknown token type');
|
||||
}
|
||||
async tokenURI(token, tokenId) {
|
||||
if (typeof token === 'string')
|
||||
token = await this.tokenInfo(token);
|
||||
if ('error' in token)
|
||||
return token;
|
||||
if (token.abi === 'ERC721') {
|
||||
const c = createContract(ERC721, this, token.contract);
|
||||
if (!token.metadata)
|
||||
return { contract: token.contract, error: 'erc721 without metadata' };
|
||||
return c.tokenURI.call(tokenId);
|
||||
}
|
||||
else if (token.abi === 'ERC1155') {
|
||||
const c = createContract(ERC1155, this, token.contract);
|
||||
return c.uri.call(tokenId);
|
||||
}
|
||||
return { contract: token.contract, error: 'not supported token type' };
|
||||
}
|
||||
async tokenBalances(address, tokens, tokenIds) {
|
||||
// New API requires data from tokenInfo (which is slow and should be cached).
|
||||
// But for compat with old API, we do tokenInfo call if contract address (as string) presented
|
||||
const _tokens = await Promise.all(tokens.map((i) => (typeof i === 'string' ? this.tokenInfo(i) : i)));
|
||||
const balances = await Promise.all(_tokens.map((i) => this.tokenBalanceSingle(address, i, tokenIds && tokenIds[i.contract])));
|
||||
return Object.fromEntries(_tokens.map((i, j) => [i.contract, balances[j]]));
|
||||
}
|
||||
decodeTokenTransfer(token, log) {
|
||||
if ('error' in token)
|
||||
return;
|
||||
if (token.abi === 'ERC20') {
|
||||
try {
|
||||
const decoded = ERC_TRANSFER.decode(log.topics, log.data);
|
||||
return {
|
||||
...token,
|
||||
contract: log.address,
|
||||
to: decoded.to,
|
||||
from: decoded.from,
|
||||
tokens: new Map([[1n, decoded.value]]),
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
// Weth doesn't issue Transfer event on Deposit/Withdrawal
|
||||
// NOTE: we don't filter for WETH_CONTRACT here in case of other contracts with similar API or different networks
|
||||
try {
|
||||
const decoded = WETH_DEPOSIT.decode(log.topics, log.data);
|
||||
return {
|
||||
...token,
|
||||
contract: log.address,
|
||||
from: log.address,
|
||||
to: decoded.dst,
|
||||
tokens: new Map([[1n, decoded.wad]]),
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
try {
|
||||
const decoded = WETH_WITHDRAW.decode(log.topics, log.data);
|
||||
return {
|
||||
...token,
|
||||
contract: log.address,
|
||||
from: decoded.src,
|
||||
to: log.address,
|
||||
tokens: new Map([[1n, decoded.wad]]),
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
else if (token.abi === 'ERC721') {
|
||||
try {
|
||||
const decoded = ERC721_TRANSFER.decode(log.topics, log.data);
|
||||
return {
|
||||
...token,
|
||||
from: decoded.from,
|
||||
to: decoded.to,
|
||||
tokens: new Map([[decoded.tokenId, 1n]]),
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
else if (token.abi === 'ERC1155') {
|
||||
try {
|
||||
const decoded = ERC1155_SINGLE.decode(log.topics, log.data);
|
||||
return {
|
||||
...token,
|
||||
from: decoded.from,
|
||||
to: decoded.to,
|
||||
tokens: new Map([[decoded.id, decoded.value]]),
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
try {
|
||||
const decoded = ERC1155_BATCH.decode(log.topics, log.data);
|
||||
return {
|
||||
...token,
|
||||
from: decoded.from,
|
||||
to: decoded.to,
|
||||
tokens: new Map(decoded.ids.map((i, j) => [i, decoded.values[j]])),
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return; // unknown token type
|
||||
}
|
||||
// We want to get all transactions related to address, that means:
|
||||
// - from or to equals address in tx
|
||||
// - any internal tx from or to equals address in tx
|
||||
// - any erc20 token transfer which hash address in src or dst
|
||||
// - erc721 is exactly same function signature as erc20 (need to detect after getting transactions)
|
||||
// - erc1155: from/to + single/batch
|
||||
// trace_filter (web3) returns information only for first two cases, most of explorers returns only first case.
|
||||
async transfers(address, opts = {}) {
|
||||
const txCache = {};
|
||||
const blockCache = {};
|
||||
const tokenCache = {};
|
||||
const _opts = {
|
||||
...opts,
|
||||
txCallback: (txHash) => {
|
||||
if (txCache[txHash])
|
||||
return;
|
||||
txCache[txHash] = this.txInfo(txHash, opts);
|
||||
},
|
||||
blockCallback: (blockNumber) => {
|
||||
if (blockCache[blockNumber])
|
||||
return;
|
||||
blockCache[blockNumber] = this.blockInfo(blockNumber);
|
||||
},
|
||||
contractCallback: (address) => {
|
||||
if (tokenCache[address])
|
||||
return;
|
||||
tokenCache[address] = this.tokenInfo(address);
|
||||
},
|
||||
};
|
||||
if (!_opts.fromBlock)
|
||||
_opts.fromBlock = 0;
|
||||
// This runs in parallel and executes callbacks
|
||||
// Note, we ignore logs and weth, but they will call callbacks and fetch related
|
||||
const [actions, _logs, _weth] = await Promise.all([
|
||||
this.internalTransactions(address, _opts),
|
||||
this.tokenTransfers(address, _opts),
|
||||
this.wethTransfers(address, _opts),
|
||||
this.erc1155Transfers(address, _opts),
|
||||
]);
|
||||
const mapCache = async (cache) => {
|
||||
const keys = Object.keys(cache);
|
||||
const values = await Promise.all(Object.values(cache));
|
||||
return Object.fromEntries(values.map((v, i) => [keys[i], v]));
|
||||
};
|
||||
// it is ok to do this sequentially, since promises already started and probably resolved at this point
|
||||
const blocks = await mapCache(blockCache);
|
||||
const tx = await mapCache(txCache);
|
||||
const tokens = await mapCache(tokenCache);
|
||||
const actionPerTx = group(actions, 'transactionHash');
|
||||
// Sort transactions by [blockNumber, transactionIndex]
|
||||
const _txHashes = Object.entries(tx).map(([k, v]) => [k, v.info.blockNumber, v.info.transactionIndex]);
|
||||
_txHashes.sort((a, b) => (a[1] !== b[1] ? a[1] - b[1] : a[2] - b[2]));
|
||||
const txHashes = _txHashes.map((i) => i[0]);
|
||||
return txHashes.map((txHash) => {
|
||||
const { info, receipt } = tx[txHash];
|
||||
const actions = actionPerTx[txHash];
|
||||
const block = info.blockNumber !== null ? blocks[info.blockNumber] : undefined;
|
||||
const transfers = [];
|
||||
if (actions) {
|
||||
for (const a of actions)
|
||||
transfers.push({ from: a.action.from, to: a.action.to, value: a.action.value });
|
||||
}
|
||||
else {
|
||||
// If we have action, it was call to contract and transfer from tx is already added
|
||||
transfers.push({ from: info.from, to: info.to, value: info.value });
|
||||
}
|
||||
// cumulativeGasUsed includes all transactions before that in block, so useless. gasUsed is correct even for internal transactions
|
||||
transfers.push({ from: info.from, value: receipt.gasUsed * receipt.effectiveGasPrice });
|
||||
// Tokens
|
||||
const tokenTransfers = [];
|
||||
for (const log of receipt.logs) {
|
||||
const tokenInfo = tokens[log.address];
|
||||
if (!tokenInfo)
|
||||
continue;
|
||||
const tt = this.decodeTokenTransfer(tokenInfo, log);
|
||||
if (tt)
|
||||
tokenTransfers.push(tt);
|
||||
}
|
||||
return {
|
||||
hash: txHash,
|
||||
timestamp: block.timestamp,
|
||||
block: info.blockNumber !== null ? info.blockNumber : undefined,
|
||||
reverted: !receipt.status,
|
||||
transfers,
|
||||
tokenTransfers,
|
||||
info: { ...tx[txHash], block, actions },
|
||||
};
|
||||
});
|
||||
}
|
||||
async allowances(address, opts = {}) {
|
||||
const approval = events(ERC20).Approval;
|
||||
// ERC-721/ERC-1155: +ApprovalForAll
|
||||
// ERC-1761 Scoped Approval for partial with 1155/721?
|
||||
const topics = approval.topics({ owner: address, spender: null, value: null });
|
||||
const logs = await this.ethLogs(topics, opts);
|
||||
// res[tokenContract][spender] = value
|
||||
const res = {};
|
||||
for (const l of logs) {
|
||||
const decoded = approval.decode(l.topics, l.data);
|
||||
if (decoded.owner.toLowerCase() !== address.toLowerCase())
|
||||
continue;
|
||||
if (!res[l.address])
|
||||
res[l.address] = {};
|
||||
res[l.address][decoded.spender] = decoded.value;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Calculates balances at specific point in time after tx.
|
||||
* Also, useful as a sanity check in case we've missed something.
|
||||
* Info from multiple addresses can be merged (sort everything first).
|
||||
*/
|
||||
export function calcTransfersDiff(transfers) {
|
||||
// address -> balance
|
||||
const balances = {};
|
||||
// contract -> address -> tokenId -> balance
|
||||
const tokenBalances = {};
|
||||
let _0 = BigInt(0);
|
||||
for (const t of transfers) {
|
||||
for (const it of t.transfers) {
|
||||
if (it.from) {
|
||||
if (balances[it.from] === undefined)
|
||||
balances[it.from] = _0;
|
||||
balances[it.from] -= it.value;
|
||||
}
|
||||
if (it.to) {
|
||||
if (balances[it.to] === undefined)
|
||||
balances[it.to] = _0;
|
||||
balances[it.to] += it.value;
|
||||
}
|
||||
}
|
||||
for (const tt of t.tokenTransfers) {
|
||||
if (!tokenBalances[tt.contract])
|
||||
tokenBalances[tt.contract] = {};
|
||||
const token = tokenBalances[tt.contract];
|
||||
for (const [tokenId, value] of tt.tokens) {
|
||||
if (token[tt.from] === undefined)
|
||||
token[tt.from] = new Map();
|
||||
if (token[tt.to] === undefined)
|
||||
token[tt.to] = new Map();
|
||||
const fromTokens = token[tt.from];
|
||||
const toTokens = token[tt.to];
|
||||
fromTokens.set(tokenId, (fromTokens.get(tokenId) || _0) - value);
|
||||
toTokens.set(tokenId, (toTokens.get(tokenId) || _0) + value);
|
||||
}
|
||||
}
|
||||
Object.assign(t, {
|
||||
balances: { ...balances },
|
||||
// deep copy
|
||||
tokenBalances: Object.fromEntries(Object.entries(tokenBalances).map(([k, v]) => [k, { ...v }])),
|
||||
});
|
||||
}
|
||||
return transfers;
|
||||
}
|
||||
//# sourceMappingURL=archive.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/archive.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/archive.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
14
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.d.ts
generated
vendored
Executable file
14
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.d.ts
generated
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
import { type IWeb3Provider } from '../utils.ts';
|
||||
export declare const TOKENS: Record<string, {
|
||||
decimals: number;
|
||||
contract: string;
|
||||
tokenContract: string;
|
||||
}>;
|
||||
export default class Chainlink {
|
||||
readonly net: IWeb3Provider;
|
||||
constructor(net: IWeb3Provider);
|
||||
price(contract: string, decimals: number): Promise<number>;
|
||||
coinPrice(symbol: string): Promise<number>;
|
||||
tokenPrice(symbol: string): Promise<number>;
|
||||
}
|
||||
//# sourceMappingURL=chainlink.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"chainlink.d.ts","sourceRoot":"","sources":["../../src/net/chainlink.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,aAAa,CAAC;AAgBhE,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAuQ9F,CAAC;AAEJ,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;gBAChB,GAAG,EAAE,aAAa;IAGxB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAe1C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAKlD"}
|
||||
313
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.js
generated
vendored
Executable file
313
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.js
generated
vendored
Executable file
@@ -0,0 +1,313 @@
|
||||
import { createContract, tokenFromSymbol } from "../abi/index.js";
|
||||
import { createDecimal } from "../utils.js";
|
||||
const ABI = [
|
||||
{
|
||||
type: 'function',
|
||||
name: 'latestRoundData',
|
||||
outputs: [
|
||||
{ name: 'roundId', type: 'uint80' },
|
||||
{ name: 'answer', type: 'int256' },
|
||||
{ name: 'startedAt', type: 'uint256' },
|
||||
{ name: 'updatedAt', type: 'uint256' },
|
||||
{ name: 'answeredInRound', type: 'uint80' },
|
||||
],
|
||||
},
|
||||
];
|
||||
export const TOKENS = {
|
||||
'1INCH': {
|
||||
decimals: 8,
|
||||
contract: '0xc929ad75b72593967de83e7f7cda0493458261d9',
|
||||
tokenContract: '0x111111111117dc0aa78b770fa6a738034120c302',
|
||||
},
|
||||
AAPL: {
|
||||
decimals: 8,
|
||||
contract: '0x139c8512cde1778e9b9a8e721ce1aebd4dd43587',
|
||||
tokenContract: '0x7edc9e8a1196259b7c6aba632037a9443d4e14f7',
|
||||
},
|
||||
AAVE: {
|
||||
decimals: 8,
|
||||
contract: '0x547a514d5e3769680ce22b2361c10ea13619e8a9',
|
||||
tokenContract: '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9',
|
||||
},
|
||||
ADX: {
|
||||
decimals: 8,
|
||||
contract: '0x231e764b44b2c1b7ca171fa8021a24ed520cde10',
|
||||
tokenContract: '0x4470bb87d77b963a013db939be332f927f2b992e',
|
||||
},
|
||||
AKRO: {
|
||||
decimals: 8,
|
||||
contract: '0xb23d105df4958b4b81757e12f2151b5b5183520b',
|
||||
tokenContract: '0x8ab7404063ec4dbcfd4598215992dc3f8ec853d7',
|
||||
},
|
||||
AMP: {
|
||||
decimals: 8,
|
||||
contract: '0x8797abc4641de76342b8ace9c63e3301dc35e3d8',
|
||||
tokenContract: '0xff20817765cb7f73d4bde2e66e067e58d11095c2',
|
||||
},
|
||||
AMPL: {
|
||||
decimals: 18,
|
||||
contract: '0xe20ca8d7546932360e37e9d72c1a47334af57706',
|
||||
tokenContract: '0xd46ba6d942050d489dbd938a2c909a5d5039a161',
|
||||
},
|
||||
AMZN: {
|
||||
decimals: 8,
|
||||
contract: '0x8994115d287207144236c13be5e2bdbf6357d9fd',
|
||||
tokenContract: '0xd6a073d973f95b7ce2ecf2b19224fa12103cf460',
|
||||
},
|
||||
ANKR: {
|
||||
decimals: 8,
|
||||
contract: '0x7eed379bf00005cfed29fed4009669de9bcc21ce',
|
||||
tokenContract: '0x8290333cef9e6d528dd5618fb97a76f268f3edd4',
|
||||
},
|
||||
BADGER: {
|
||||
decimals: 8,
|
||||
contract: '0x66a47b7206130e6ff64854ef0e1edfa237e65339',
|
||||
tokenContract: '0x3472a5a71965499acd81997a54bba8d852c6e53d',
|
||||
},
|
||||
BAND: {
|
||||
decimals: 8,
|
||||
contract: '0x919c77acc7373d000b329c1276c76586ed2dd19f',
|
||||
tokenContract: '0xba11d00c5f74255f56a5e366f4f77f5a186d7f55',
|
||||
},
|
||||
BAT: {
|
||||
decimals: 8,
|
||||
contract: '0x9441d7556e7820b5ca42082cfa99487d56aca958',
|
||||
tokenContract: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
||||
},
|
||||
BNB: {
|
||||
decimals: 8,
|
||||
contract: '0x14e613ac84a31f709eadbdf89c6cc390fdc9540a',
|
||||
tokenContract: '0xb8c77482e45f1f44de1745f52c74426c631bdd52',
|
||||
},
|
||||
BNT: {
|
||||
decimals: 8,
|
||||
contract: '0x1e6cf0d433de4fe882a437abc654f58e1e78548c',
|
||||
tokenContract: '0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c',
|
||||
},
|
||||
BTM: {
|
||||
decimals: 8,
|
||||
contract: '0x9fccf42d21ab278e205e7bb310d8979f8f4b5751',
|
||||
tokenContract: '0xcb97e65f07da24d46bcdd078ebebd7c6e6e3d750',
|
||||
},
|
||||
BUSD: {
|
||||
decimals: 8,
|
||||
contract: '0x833d8eb16d306ed1fbb5d7a2e019e106b960965a',
|
||||
tokenContract: '0x4fabb145d64652a948d72533023f6e7a623c7c53',
|
||||
},
|
||||
COMP: {
|
||||
decimals: 8,
|
||||
contract: '0xdbd020caef83efd542f4de03e3cf0c28a4428bd5',
|
||||
tokenContract: '0xc00e94cb662c3520282e6f5717214004a7f26888',
|
||||
},
|
||||
COVER: {
|
||||
decimals: 8,
|
||||
contract: '0x0ad50393f11ffac4dd0fe5f1056448ecb75226cf',
|
||||
tokenContract: '0x4688a8b1f292fdab17e9a90c8bc379dc1dbd8713',
|
||||
},
|
||||
CRO: {
|
||||
decimals: 8,
|
||||
contract: '0x00cb80cf097d9aa9a3779ad8ee7cf98437eae050',
|
||||
tokenContract: '0xa0b73e1ff0b80914ab6fe0444e65848c4c34450b',
|
||||
},
|
||||
CRV: {
|
||||
decimals: 8,
|
||||
contract: '0xcd627aa160a6fa45eb793d19ef54f5062f20f33f',
|
||||
tokenContract: '0xd533a949740bb3306d119cc777fa900ba034cd52',
|
||||
},
|
||||
DAI: {
|
||||
decimals: 8,
|
||||
contract: '0xaed0c38402a5d19df6e4c03f4e2dced6e29c1ee9',
|
||||
tokenContract: '0x60d9564303c70d3f040ea9393d98d94f767d020c',
|
||||
},
|
||||
DPI: {
|
||||
decimals: 8,
|
||||
contract: '0xd2a593bf7594ace1fad597adb697b5645d5eddb2',
|
||||
tokenContract: '0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b',
|
||||
},
|
||||
EOS: {
|
||||
decimals: 8,
|
||||
contract: '0x10a43289895eaff840e8d45995bba89f9115ecee',
|
||||
tokenContract: '0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0',
|
||||
},
|
||||
FXS: {
|
||||
decimals: 8,
|
||||
contract: '0x6ebc52c8c1089be9eb3945c4350b68b8e4c2233f',
|
||||
tokenContract: '0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0',
|
||||
},
|
||||
HT: {
|
||||
decimals: 8,
|
||||
contract: '0xe1329b3f6513912caf589659777b66011aee5880',
|
||||
tokenContract: '0x6f259637dcd74c767781e37bc6133cd6a68aa161',
|
||||
},
|
||||
IOST: {
|
||||
decimals: 8,
|
||||
contract: '0xd0935838935349401c73a06fcde9d63f719e84e5',
|
||||
tokenContract: '0xfa1a856cfa3409cfa145fa4e20eb270df3eb21ab',
|
||||
},
|
||||
KNC: {
|
||||
decimals: 8,
|
||||
contract: '0xf8ff43e991a81e6ec886a3d281a2c6cc19ae70fc',
|
||||
tokenContract: '0xdd974d5c2e2928dea5f71b9825b8b646686bd200',
|
||||
},
|
||||
LINK: {
|
||||
decimals: 8,
|
||||
contract: '0x2c1d072e956affc0d435cb7ac38ef18d24d9127c',
|
||||
tokenContract: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
||||
},
|
||||
LRC: {
|
||||
decimals: 8,
|
||||
contract: '0xfd33ec6abaa1bdc3d9c6c85f1d6299e5a1a5511f',
|
||||
tokenContract: '0xef68e7c694f40c8202821edf525de3782458639f',
|
||||
},
|
||||
MATIC: {
|
||||
decimals: 8,
|
||||
contract: '0x7bac85a8a13a4bcd8abb3eb7d6b4d632c5a57676',
|
||||
tokenContract: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
|
||||
},
|
||||
MKR: {
|
||||
decimals: 8,
|
||||
contract: '0xec1d1b3b0443256cc3860e24a46f108e699484aa',
|
||||
tokenContract: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
|
||||
},
|
||||
MTA: {
|
||||
decimals: 8,
|
||||
contract: '0xc751e86208f0f8af2d5cd0e29716ca7ad98b5ef5',
|
||||
tokenContract: '0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2',
|
||||
},
|
||||
NFLX: {
|
||||
decimals: 8,
|
||||
contract: '0x67c2e69c5272b94af3c90683a9947c39dc605dde',
|
||||
tokenContract: '0x0a3dc37762f0102175fd43d3871d7fa855626146',
|
||||
},
|
||||
NMR: {
|
||||
decimals: 8,
|
||||
contract: '0xcc445b35b3636bc7cc7051f4769d8982ed0d449a',
|
||||
tokenContract: '0x1776e1f26f98b1a5df9cd347953a26dd3cb46671',
|
||||
},
|
||||
OCEAN: {
|
||||
decimals: 8,
|
||||
contract: '0x7ece4e4e206ed913d991a074a19c192142726797',
|
||||
tokenContract: '0x967da4048cd07ab37855c090aaf366e4ce1b9f48',
|
||||
},
|
||||
OKB: {
|
||||
decimals: 8,
|
||||
contract: '0x22134617ae0f6ca8d89451e5ae091c94f7d743dc',
|
||||
tokenContract: '0x75231f58b43240c9718dd58b4967c5114342a86c',
|
||||
},
|
||||
OMG: {
|
||||
decimals: 8,
|
||||
contract: '0x7d476f061f8212a8c9317d5784e72b4212436e93',
|
||||
tokenContract: '0xd26114cd6ee289accf82350c8d8487fedb8a0c07',
|
||||
},
|
||||
OXT: {
|
||||
decimals: 8,
|
||||
contract: '0xd75aaae4af0c398ca13e2667be57af2cca8b5de6',
|
||||
tokenContract: '0x4575f41308ec1483f3d399aa9a2826d74da13deb',
|
||||
},
|
||||
REN: {
|
||||
decimals: 8,
|
||||
contract: '0x0f59666ede214281e956cb3b2d0d69415aff4a01',
|
||||
tokenContract: '0x408e41876cccdc0f92210600ef50372656052a38',
|
||||
},
|
||||
SAND: {
|
||||
decimals: 8,
|
||||
contract: '0x35e3f7e558c04ce7eee1629258ecbba03b36ec56',
|
||||
tokenContract: '0x3845badade8e6dff049820680d1f14bd3903a5d0',
|
||||
},
|
||||
SNX: {
|
||||
decimals: 8,
|
||||
contract: '0xdc3ea94cd0ac27d9a86c180091e7f78c683d3699',
|
||||
tokenContract: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
|
||||
},
|
||||
SUSHI: {
|
||||
decimals: 8,
|
||||
contract: '0xcc70f09a6cc17553b2e31954cd36e4a2d89501f7',
|
||||
tokenContract: '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2',
|
||||
},
|
||||
SXP: {
|
||||
decimals: 8,
|
||||
contract: '0xfb0cfd6c19e25db4a08d8a204a387cea48cc138f',
|
||||
tokenContract: '0x8ce9137d39326ad0cd6491fb5cc0cba0e089b6a9',
|
||||
},
|
||||
UNI: {
|
||||
decimals: 8,
|
||||
contract: '0x553303d460ee0afb37edff9be42922d8ff63220e',
|
||||
tokenContract: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
|
||||
},
|
||||
USDC: {
|
||||
decimals: 8,
|
||||
contract: '0x8fffffd4afb6115b954bd326cbe7b4ba576818f6',
|
||||
tokenContract: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
||||
},
|
||||
USDK: {
|
||||
decimals: 8,
|
||||
contract: '0xfac81ea9dd29d8e9b212acd6edbeb6de38cb43af',
|
||||
tokenContract: '0x1c48f86ae57291f7686349f12601910bd8d470bb',
|
||||
},
|
||||
USDT: {
|
||||
decimals: 8,
|
||||
contract: '0x3e7d1eab13ad0104d2750b8863b489d65364e32d',
|
||||
tokenContract: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
||||
},
|
||||
YFI: {
|
||||
decimals: 8,
|
||||
contract: '0xa027702dbb89fbd58938e4324ac03b58d812b0e1',
|
||||
tokenContract: '0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e',
|
||||
},
|
||||
ZRX: {
|
||||
decimals: 8,
|
||||
contract: '0x2885d15b8af22648b98b122b22fdf4d2a56c6023',
|
||||
tokenContract: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||
},
|
||||
SUSD: {
|
||||
decimals: 8,
|
||||
contract: '0xad35bd71b9afe6e4bdc266b345c198eadef9ad94',
|
||||
tokenContract: '0x57ab1e02fee23774580c119740129eac7081e9d3',
|
||||
},
|
||||
// Wrapped tokens uses price of original coin
|
||||
WBTC: {
|
||||
decimals: 8,
|
||||
contract: '0xf4030086522a5beea4988f8ca5b36dbc97bee88c',
|
||||
tokenContract: tokenFromSymbol('WBTC').contract,
|
||||
},
|
||||
WETH: {
|
||||
decimals: 8,
|
||||
contract: '0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419',
|
||||
tokenContract: tokenFromSymbol('WETH').contract,
|
||||
},
|
||||
};
|
||||
export default class Chainlink {
|
||||
constructor(net) {
|
||||
this.net = net;
|
||||
}
|
||||
async price(contract, decimals) {
|
||||
const prices = createContract(ABI, this.net, contract);
|
||||
let res = await prices.latestRoundData.call();
|
||||
const num = Number.parseFloat(createDecimal(decimals).encode(res.answer));
|
||||
if (Number.isNaN(num))
|
||||
throw new Error('invalid data received');
|
||||
return num;
|
||||
}
|
||||
async coinPrice(symbol) {
|
||||
// Only common coins
|
||||
const COINS = {
|
||||
BCH: { decimals: 8, contract: '0x9f0f69428f923d6c95b781f89e165c9b2df9789d' },
|
||||
BTC: { decimals: 8, contract: '0xf4030086522a5beea4988f8ca5b36dbc97bee88c' },
|
||||
DOGE: { decimals: 8, contract: '0x2465cefd3b488be410b941b1d4b2767088e2a028' },
|
||||
ETH: { decimals: 8, contract: '0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419' },
|
||||
XMR: { decimals: 8, contract: '0xfa66458cce7dd15d8650015c4fce4d278271618f' },
|
||||
ZEC: { decimals: 8, contract: '0xd54b033d48d0475f19c5fccf7484e8a981848501' },
|
||||
};
|
||||
const coin = COINS[symbol.toUpperCase()];
|
||||
if (!coin)
|
||||
throw new Error(`micro-web3/chainlink: unknown coin: ${symbol}`);
|
||||
return await this.price(coin.contract, coin.decimals);
|
||||
}
|
||||
async tokenPrice(symbol) {
|
||||
const token = TOKENS[symbol.toUpperCase()];
|
||||
if (!token)
|
||||
throw new Error(`micro-web3/chainlink: unknown token: ${symbol}`);
|
||||
return await this.price(token.contract, token.decimals);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=chainlink.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/chainlink.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
44
dev/env/node_modules/micro-eth-signer/esm/net/ens.d.ts
generated
vendored
Executable file
44
dev/env/node_modules/micro-eth-signer/esm/net/ens.d.ts
generated
vendored
Executable file
@@ -0,0 +1,44 @@
|
||||
import { type IWeb3Provider } from '../utils.ts';
|
||||
export declare function namehash(address: string): Uint8Array;
|
||||
export default class ENS {
|
||||
static ADDRESS_ZERO: string;
|
||||
static REGISTRY: string;
|
||||
static REGISTRY_CONTRACT: readonly [{
|
||||
readonly name: "resolver";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "node";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "address";
|
||||
}];
|
||||
}];
|
||||
static RESOLVER_CONTRACT: readonly [{
|
||||
readonly name: "addr";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "node";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "address";
|
||||
}];
|
||||
}, {
|
||||
readonly name: "name";
|
||||
readonly type: "function";
|
||||
readonly inputs: readonly [{
|
||||
readonly name: "node";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly outputs: readonly [{
|
||||
readonly type: "string";
|
||||
}];
|
||||
}];
|
||||
readonly net: IWeb3Provider;
|
||||
constructor(net: IWeb3Provider);
|
||||
getResolver(name: string): Promise<string | undefined>;
|
||||
nameToAddress(name: string): Promise<string | undefined>;
|
||||
addressToName(address: string): Promise<string | undefined>;
|
||||
}
|
||||
//# sourceMappingURL=ens.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/ens.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/ens.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ens.d.ts","sourceRoot":"","sources":["../../src/net/ens.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,aAAa,CAAC;AAG1D,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAMpD;AAED,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,MAAM,CAAC,YAAY,SAAgD;IACnE,MAAM,CAAC,QAAQ,SAAgD;IAC/D,MAAM,CAAC,iBAAiB;;;;;;;;;;OAOb;IACX,MAAM,CAAC,iBAAiB;;;;;;;;;;;;;;;;;;;;OAab;IAEX,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;gBAChB,GAAG,EAAE,aAAa;IAGxB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAOtD,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IASxD,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAelE"}
|
||||
79
dev/env/node_modules/micro-eth-signer/esm/net/ens.js
generated
vendored
Executable file
79
dev/env/node_modules/micro-eth-signer/esm/net/ens.js
generated
vendored
Executable file
@@ -0,0 +1,79 @@
|
||||
import { keccak_256 } from '@noble/hashes/sha3';
|
||||
import { concatBytes } from '@noble/hashes/utils';
|
||||
import { createContract } from "../abi/decoder.js";
|
||||
import { strip0x } from "../utils.js";
|
||||
// No support for IDN names
|
||||
export function namehash(address) {
|
||||
let res = new Uint8Array(32);
|
||||
if (!address)
|
||||
return res;
|
||||
for (let label of address.split('.').reverse())
|
||||
res = keccak_256(concatBytes(res, keccak_256(label)));
|
||||
return res;
|
||||
}
|
||||
class ENS {
|
||||
constructor(net) {
|
||||
this.net = net;
|
||||
}
|
||||
async getResolver(name) {
|
||||
const contract = createContract(ENS.REGISTRY_CONTRACT, this.net, ENS.REGISTRY);
|
||||
const res = await contract.resolver.call(namehash(name));
|
||||
if (res === ENS.ADDRESS_ZERO)
|
||||
return;
|
||||
return res;
|
||||
}
|
||||
async nameToAddress(name) {
|
||||
const resolver = await this.getResolver(name);
|
||||
if (!resolver)
|
||||
return;
|
||||
const contract = createContract(ENS.RESOLVER_CONTRACT, this.net, resolver);
|
||||
const addr = await contract.addr.call(namehash(name));
|
||||
if (addr === ENS.ADDRESS_ZERO)
|
||||
return;
|
||||
return addr;
|
||||
}
|
||||
async addressToName(address) {
|
||||
const addrDomain = `${strip0x(address).toLowerCase()}.addr.reverse`;
|
||||
const resolver = await this.getResolver(addrDomain);
|
||||
if (!resolver)
|
||||
return;
|
||||
const contract = createContract(ENS.RESOLVER_CONTRACT, this.net, resolver);
|
||||
const name = await contract.name.call(namehash(addrDomain));
|
||||
if (!name)
|
||||
return;
|
||||
// From spec: ENS does not enforce accuracy of reverse records -
|
||||
// anyone may claim that the name for their address is 'alice.eth'.
|
||||
// To be certain the claim is accurate, you must always perform a forward
|
||||
// resolution for the returned name and check whether it matches the original address.
|
||||
const realAddr = await this.nameToAddress(name);
|
||||
if (realAddr !== address)
|
||||
return;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
ENS.ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
|
||||
ENS.REGISTRY = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e';
|
||||
ENS.REGISTRY_CONTRACT = [
|
||||
{
|
||||
name: 'resolver',
|
||||
type: 'function',
|
||||
inputs: [{ name: 'node', type: 'bytes32' }],
|
||||
outputs: [{ type: 'address' }],
|
||||
},
|
||||
];
|
||||
ENS.RESOLVER_CONTRACT = [
|
||||
{
|
||||
name: 'addr',
|
||||
type: 'function',
|
||||
inputs: [{ name: 'node', type: 'bytes32' }],
|
||||
outputs: [{ type: 'address' }],
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
type: 'function',
|
||||
inputs: [{ name: 'node', type: 'bytes32' }],
|
||||
outputs: [{ type: 'string' }],
|
||||
},
|
||||
];
|
||||
export default ENS;
|
||||
//# sourceMappingURL=ens.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/ens.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/ens.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ens.js","sourceRoot":"","sources":["../../src/net/ens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAsB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE1D,2BAA2B;AAC3B,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,IAAI,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC;IACzB,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE;QAC5C,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAqB,GAAG;IA2BtB,YAAY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,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,gEAAgE;QAChE,mEAAmE;QACnE,yEAAyE;QACzE,sFAAsF;QACtF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,QAAQ,KAAK,OAAO;YAAE,OAAO;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;;AA3DM,gBAAY,GAAG,4CAA4C,CAAC;AAC5D,YAAQ,GAAG,4CAA4C,CAAC;AACxD,qBAAiB,GAAG;IACzB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC/B;CACO,CAAC;AACJ,qBAAiB,GAAG;IACzB;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC/B;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;KAC9B;CACO,CAAC;eAxBQ,GAAG"}
|
||||
7
dev/env/node_modules/micro-eth-signer/esm/net/index.d.ts
generated
vendored
Executable file
7
dev/env/node_modules/micro-eth-signer/esm/net/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
import { Web3Provider, calcTransfersDiff } from './archive.ts';
|
||||
import Chainlink from './chainlink.ts';
|
||||
import ENS from './ens.ts';
|
||||
import UniswapV2 from './uniswap-v2.ts';
|
||||
import UniswapV3 from './uniswap-v3.ts';
|
||||
export { Chainlink, ENS, UniswapV2, UniswapV3, Web3Provider, calcTransfersDiff };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/index.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/index.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/net/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
||||
8
dev/env/node_modules/micro-eth-signer/esm/net/index.js
generated
vendored
Executable file
8
dev/env/node_modules/micro-eth-signer/esm/net/index.js
generated
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
import { Web3Provider, calcTransfersDiff } from "./archive.js";
|
||||
import Chainlink from "./chainlink.js";
|
||||
import ENS from "./ens.js";
|
||||
import UniswapV2 from "./uniswap-v2.js";
|
||||
import UniswapV3 from "./uniswap-v3.js";
|
||||
// There are many low level APIs inside which are not exported yet.
|
||||
export { Chainlink, ENS, UniswapV2, UniswapV3, Web3Provider, calcTransfersDiff };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/index.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/net/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC,mEAAmE;AACnE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
||||
72
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.d.ts
generated
vendored
Executable file
72
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.d.ts
generated
vendored
Executable file
@@ -0,0 +1,72 @@
|
||||
import { type IWeb3Provider } from '../utils.ts';
|
||||
export type SwapOpt = {
|
||||
slippagePercent: number;
|
||||
ttl: number;
|
||||
};
|
||||
export declare const DEFAULT_SWAP_OPT: SwapOpt;
|
||||
export type ExchangeTx = {
|
||||
address: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
expectedAmount: string;
|
||||
data?: string;
|
||||
allowance?: {
|
||||
token: string;
|
||||
contract: string;
|
||||
amount: string;
|
||||
};
|
||||
txId?: string;
|
||||
};
|
||||
export type SwapElm = {
|
||||
name: string;
|
||||
expectedAmount: string;
|
||||
tx: (fromAddress: string, toAddress: string) => Promise<ExchangeTx>;
|
||||
};
|
||||
export declare function addPercent(n: bigint, _perc: number): bigint;
|
||||
export declare function isPromise(o: unknown): boolean;
|
||||
export type UnPromise<T> = T extends Promise<infer U> ? U : T;
|
||||
type NestedUnPromise<T> = {
|
||||
[K in keyof T]: NestedUnPromise<UnPromise<T[K]>>;
|
||||
};
|
||||
type UnPromiseIgnore<T> = T extends Promise<infer U> ? U | undefined : T;
|
||||
type NestedUnPromiseIgnore<T> = {
|
||||
[K in keyof T]: NestedUnPromiseIgnore<UnPromiseIgnore<T[K]>>;
|
||||
};
|
||||
export declare function awaitDeep<T, E extends boolean | undefined>(o: T, ignore_errors: E): Promise<E extends true ? NestedUnPromiseIgnore<T> : NestedUnPromise<T>>;
|
||||
export type CommonBase = {
|
||||
contract: string;
|
||||
} & import('../abi/decoder.js').ContractInfo;
|
||||
export declare const COMMON_BASES: CommonBase[];
|
||||
export declare const WETH: string;
|
||||
export declare function wrapContract(contract: string): string;
|
||||
export declare function sortTokens(a: string, b: string): [string, string];
|
||||
export declare function isValidEthAddr(address: string): boolean;
|
||||
export declare function isValidUniAddr(address: string): boolean;
|
||||
export type Token = {
|
||||
decimals: number;
|
||||
contract: string;
|
||||
symbol: string;
|
||||
};
|
||||
export declare abstract class UniswapAbstract {
|
||||
abstract name: string;
|
||||
abstract contract: string;
|
||||
abstract bestPath(fromCoin: string, toCoin: string, inputAmount: bigint): any;
|
||||
abstract txData(toAddress: string, fromCoin: string, toCoin: string, path: any, inputAmount?: bigint, outputAmount?: bigint, opt?: {
|
||||
slippagePercent: number;
|
||||
}): any;
|
||||
readonly net: IWeb3Provider;
|
||||
constructor(net: IWeb3Provider);
|
||||
swap(fromCoin: 'eth' | Token, toCoin: 'eth' | Token, amount: string, opt?: SwapOpt): Promise<{
|
||||
name: string;
|
||||
expectedAmount: string;
|
||||
tx: (_fromAddress: string, toAddress: string) => Promise<{
|
||||
amount: string;
|
||||
address: any;
|
||||
expectedAmount: string;
|
||||
data: string;
|
||||
allowance: any;
|
||||
}>;
|
||||
} | undefined>;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=uniswap-common.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":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QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG;IAC7E,QAAQ,CAAC,MAAM,CACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,GAAG,CAAC,EAAE;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,GAChC,GAAG;IACN,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;gBAChB,GAAG,EAAE,aAAa;IAQxB,IAAI,CACR,QAAQ,EAAE,KAAK,GAAG,KAAK,EACvB,MAAM,EAAE,KAAK,GAAG,KAAK,EACrB,MAAM,EAAE,MAAM,EACd,GAAG,GAAE,OAA0B,GAC9B,OAAO,CACN;QACE,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,CAAC;QACvB,EAAE,EAAE,CACF,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,KACd,OAAO,CAAC;YACX,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,GAAG,CAAC;YACb,cAAc,EAAE,MAAM,CAAC;YACvB,IAAI,EAAE,MAAM,CAAC;YACb,SAAS,EAAE,GAAG,CAAC;SAChB,CAAC,CAAC;KACJ,GACD,SAAS,CACZ;CA6CF"}
|
||||
143
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.js
generated
vendored
Executable file
143
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.js
generated
vendored
Executable file
@@ -0,0 +1,143 @@
|
||||
import { tokenFromSymbol } from "../abi/index.js";
|
||||
import { addr } from "../index.js";
|
||||
import { createDecimal, ethHex, isBytes, weieth } from "../utils.js";
|
||||
export const DEFAULT_SWAP_OPT = { slippagePercent: 0.5, ttl: 30 * 60 };
|
||||
export function addPercent(n, _perc) {
|
||||
const perc = BigInt((_perc * 10000) | 0);
|
||||
const p100 = BigInt(100) * BigInt(10000);
|
||||
return ((p100 + perc) * n) / p100;
|
||||
}
|
||||
export function isPromise(o) {
|
||||
if (!o || !['object', 'function'].includes(typeof o))
|
||||
return false;
|
||||
return typeof o.then === 'function';
|
||||
}
|
||||
export async function awaitDeep(o, ignore_errors) {
|
||||
let promises = [];
|
||||
const traverse = (o) => {
|
||||
if (Array.isArray(o))
|
||||
return o.map((i) => traverse(i));
|
||||
if (isBytes(o))
|
||||
return o;
|
||||
if (isPromise(o))
|
||||
return { awaitDeep: promises.push(o) };
|
||||
if (typeof o === 'object') {
|
||||
let ret = {};
|
||||
for (let k in o)
|
||||
ret[k] = traverse(o[k]);
|
||||
return ret;
|
||||
}
|
||||
return o;
|
||||
};
|
||||
let out = traverse(o);
|
||||
let values;
|
||||
if (!ignore_errors)
|
||||
values = await Promise.all(promises);
|
||||
else {
|
||||
values = (await Promise.allSettled(promises)).map((i) => i.status === 'fulfilled' ? i.value : undefined);
|
||||
}
|
||||
const trBack = (o) => {
|
||||
if (Array.isArray(o))
|
||||
return o.map((i) => trBack(i));
|
||||
if (isBytes(o))
|
||||
return o;
|
||||
if (typeof o === 'object') {
|
||||
if (typeof o === 'object' && o.awaitDeep)
|
||||
return values[o.awaitDeep - 1];
|
||||
let ret = {};
|
||||
for (let k in o)
|
||||
ret[k] = trBack(o[k]);
|
||||
return ret;
|
||||
}
|
||||
return o;
|
||||
};
|
||||
return trBack(out);
|
||||
}
|
||||
export const COMMON_BASES = [
|
||||
'WETH',
|
||||
'DAI',
|
||||
'USDC',
|
||||
'USDT',
|
||||
'COMP',
|
||||
'MKR',
|
||||
'WBTC',
|
||||
'AMPL',
|
||||
]
|
||||
.map((i) => tokenFromSymbol(i))
|
||||
.filter((i) => !!i);
|
||||
export const WETH = tokenFromSymbol('WETH').contract;
|
||||
if (!WETH)
|
||||
throw new Error('WETH is undefined!');
|
||||
export function wrapContract(contract) {
|
||||
contract = contract.toLowerCase();
|
||||
return contract === 'eth' ? WETH : contract;
|
||||
}
|
||||
export function sortTokens(a, b) {
|
||||
a = wrapContract(a);
|
||||
b = wrapContract(b);
|
||||
if (a === b)
|
||||
throw new Error('uniswap.sortTokens: same token!');
|
||||
return a < b ? [a, b] : [b, a];
|
||||
}
|
||||
export function isValidEthAddr(address) {
|
||||
return addr.isValid(address);
|
||||
}
|
||||
export function isValidUniAddr(address) {
|
||||
return address === 'eth' || isValidEthAddr(address);
|
||||
}
|
||||
function getToken(token) {
|
||||
if (typeof token === 'string' && token.toLowerCase() === 'eth')
|
||||
return { symbol: 'ETH', decimals: 18, contract: 'eth' };
|
||||
return token;
|
||||
}
|
||||
export class UniswapAbstract {
|
||||
constructor(net) {
|
||||
this.net = net;
|
||||
}
|
||||
// private async coinInfo(netName: string) {
|
||||
// if (!validateAddr(netName)) return;
|
||||
// if (netName === 'eth') return { symbol: 'ETH', decimals: 18 };
|
||||
// //return await this.mgr.tokenInfo('eth', netName);
|
||||
// }
|
||||
async swap(fromCoin, toCoin, amount, opt = DEFAULT_SWAP_OPT) {
|
||||
const fromInfo = getToken(fromCoin);
|
||||
const toInfo = getToken(toCoin);
|
||||
if (!fromInfo || !toInfo)
|
||||
return;
|
||||
const fromContract = fromInfo.contract.toLowerCase();
|
||||
const toContract = toInfo.contract.toLowerCase();
|
||||
if (!fromContract || !toContract)
|
||||
return;
|
||||
const fromDecimal = createDecimal(fromInfo.decimals);
|
||||
const toDecimal = createDecimal(toInfo.decimals);
|
||||
const inputAmount = fromDecimal.decode(amount);
|
||||
try {
|
||||
const path = await this.bestPath(fromContract, toContract, inputAmount);
|
||||
const expectedAmount = toDecimal.encode(path.amountOut);
|
||||
return {
|
||||
name: this.name,
|
||||
expectedAmount,
|
||||
tx: async (_fromAddress, toAddress) => {
|
||||
const txUni = this.txData(toAddress, fromContract, toContract, path, inputAmount, undefined, opt);
|
||||
return {
|
||||
amount: weieth.encode(txUni.value),
|
||||
address: txUni.to,
|
||||
expectedAmount,
|
||||
data: ethHex.encode(txUni.data),
|
||||
allowance: txUni.allowance && {
|
||||
token: txUni.allowance.token,
|
||||
contract: this.contract,
|
||||
amount: fromDecimal.encode(txUni.allowance.amount),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
// @ts-ignore
|
||||
console.log('E', e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=uniswap-common.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-common.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
30
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.d.ts
generated
vendored
Executable file
30
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.d.ts
generated
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
import * as uni from './uniswap-common.ts';
|
||||
export declare function create2(from: Uint8Array, salt: Uint8Array, initCodeHash: Uint8Array): string;
|
||||
export declare function pairAddress(a: string, b: string, factory?: string): string;
|
||||
export declare function amount(reserveIn: bigint, reserveOut: bigint, amountIn?: bigint, amountOut?: bigint): bigint;
|
||||
export type Path = {
|
||||
path: string[];
|
||||
amountIn: bigint;
|
||||
amountOut: bigint;
|
||||
};
|
||||
export declare function txData(to: string, input: string, output: string, path: Path, amountIn?: bigint, amountOut?: bigint, opt?: {
|
||||
ttl: number;
|
||||
deadline?: number;
|
||||
slippagePercent: number;
|
||||
feeOnTransfer: boolean;
|
||||
}): {
|
||||
to: string;
|
||||
value: bigint;
|
||||
data: any;
|
||||
allowance: {
|
||||
token: string;
|
||||
amount: bigint;
|
||||
} | undefined;
|
||||
};
|
||||
export default class UniswapV2 extends uni.UniswapAbstract {
|
||||
name: string;
|
||||
contract: string;
|
||||
bestPath(fromCoin: string, toCoin: string, inputAmount: bigint): Promise<Path>;
|
||||
txData(toAddress: string, fromCoin: string, toCoin: string, path: any, inputAmount?: bigint, outputAmount?: bigint, opt?: uni.SwapOpt): any;
|
||||
}
|
||||
//# sourceMappingURL=uniswap-v2.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"uniswap-v2.d.ts","sourceRoot":"","sources":["../../src/net/uniswap-v2.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAkB3C,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,GAAG,MAAM,CAG5F;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,MAAwB,GAAG,MAAM,CAI3F;AAaD,wBAAgB,MAAM,CACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAeR;AAED,MAAM,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AA8D3E,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,GAAG,GAAE;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;CACP,GACjB;IACD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EACL;QACE,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,GACD,SAAS,CAAC;CACf,CAqCA;AAGD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,GAAG,CAAC,eAAe;IACxD,IAAI,SAAgB;IACpB,QAAQ,EAAE,MAAM,CAA8B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAG9E,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,GAAG,GAAE,GAAG,CAAC,OAA8B,GACtC,GAAG;CAMP"}
|
||||
162
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.js
generated
vendored
Executable file
162
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.js
generated
vendored
Executable file
@@ -0,0 +1,162 @@
|
||||
import { keccak_256 } from '@noble/hashes/sha3';
|
||||
import { concatBytes, hexToBytes } from '@noble/hashes/utils';
|
||||
import { createContract } from "../abi/decoder.js";
|
||||
import { default as UNISWAP_V2_ROUTER, UNISWAP_V2_ROUTER_CONTRACT } from "../abi/uniswap-v2.js";
|
||||
import { ethHex } from "../utils.js";
|
||||
import * as uni from "./uniswap-common.js";
|
||||
const FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
|
||||
const INIT_CODE_HASH = hexToBytes('96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f');
|
||||
const PAIR_CONTRACT = [
|
||||
{
|
||||
type: 'function',
|
||||
name: 'getReserves',
|
||||
outputs: [
|
||||
{ name: 'reserve0', type: 'uint112' },
|
||||
{ name: 'reserve1', type: 'uint112' },
|
||||
{ name: 'blockTimestampLast', type: 'uint32' },
|
||||
],
|
||||
},
|
||||
];
|
||||
export function create2(from, salt, initCodeHash) {
|
||||
const cat = concatBytes(new Uint8Array([255]), from, salt, initCodeHash);
|
||||
return ethHex.encode(keccak_256(cat).slice(12));
|
||||
}
|
||||
export function pairAddress(a, b, factory = FACTORY_ADDRESS) {
|
||||
// This is completely broken: '0x11' '0x11' will return '0x1111'. But this is how it works in sdk.
|
||||
const data = concatBytes(...uni.sortTokens(a, b).map((i) => ethHex.decode(i)));
|
||||
return create2(ethHex.decode(factory), keccak_256(data), INIT_CODE_HASH);
|
||||
}
|
||||
async function reserves(net, a, b) {
|
||||
a = uni.wrapContract(a);
|
||||
b = uni.wrapContract(b);
|
||||
const contract = createContract(PAIR_CONTRACT, net, pairAddress(a, b));
|
||||
const res = await contract.getReserves.call();
|
||||
return a < b ? [res.reserve0, res.reserve1] : [res.reserve1, res.reserve0];
|
||||
}
|
||||
// amountIn set: returns amountOut, how many tokenB user gets for amountIn of tokenA
|
||||
// amountOut set: returns amountIn, how many tokenA user should send to get exact
|
||||
// amountOut of tokenB
|
||||
export function amount(reserveIn, reserveOut, amountIn, amountOut) {
|
||||
if (amountIn && amountOut)
|
||||
throw new Error('uniswap.amount: provide only one amount');
|
||||
if (!reserveIn || !reserveOut || (amountOut && amountOut >= reserveOut))
|
||||
throw new Error('Uniswap: Insufficient reserves');
|
||||
if (amountIn) {
|
||||
const amountInWithFee = amountIn * BigInt(997);
|
||||
const amountOut = (amountInWithFee * reserveOut) / (reserveIn * BigInt(1000) + amountInWithFee);
|
||||
if (amountOut === BigInt(0) || amountOut >= reserveOut)
|
||||
throw new Error('Uniswap: Insufficient reserves');
|
||||
return amountOut;
|
||||
}
|
||||
else if (amountOut)
|
||||
return ((reserveIn * amountOut * BigInt(1000)) / ((reserveOut - amountOut) * BigInt(997)) + BigInt(1));
|
||||
else
|
||||
throw new Error('uniswap.amount: provide only one amount');
|
||||
}
|
||||
async function bestPath(net, tokenA, tokenB, amountIn, amountOut) {
|
||||
if ((amountIn && amountOut) || (!amountIn && !amountOut))
|
||||
throw new Error('uniswap.bestPath: provide only one amount');
|
||||
const wA = uni.wrapContract(tokenA);
|
||||
const wB = uni.wrapContract(tokenB);
|
||||
let resP = [];
|
||||
// Direct pair
|
||||
resP.push((async () => {
|
||||
const pairAmount = amount(...(await reserves(net, tokenA, tokenB)), amountIn, amountOut);
|
||||
return {
|
||||
path: [wA, wB],
|
||||
amountIn: amountIn ? amountIn : pairAmount,
|
||||
amountOut: amountOut ? amountOut : pairAmount,
|
||||
};
|
||||
})());
|
||||
const BASES = uni.COMMON_BASES.filter((c) => c && c.contract && c.contract !== wA && c.contract !== wB);
|
||||
for (let c of BASES) {
|
||||
resP.push((async () => {
|
||||
const [rAC, rCB] = await Promise.all([
|
||||
reserves(net, wA, c.contract),
|
||||
reserves(net, c.contract, wB),
|
||||
]);
|
||||
const path = [wA, c.contract, wB];
|
||||
if (amountIn)
|
||||
return { path, amountIn, amountOut: amount(...rCB, amount(...rAC, amountIn)) };
|
||||
else if (amountOut) {
|
||||
return {
|
||||
path,
|
||||
amountOut,
|
||||
amountIn: amount(...rAC, undefined, amount(...rCB, undefined, amountOut)),
|
||||
};
|
||||
}
|
||||
else
|
||||
throw new Error('Impossible invariant');
|
||||
})());
|
||||
}
|
||||
let res = (await uni.awaitDeep(resP, true)).filter((i) => !!i);
|
||||
// biggest output or smallest input
|
||||
res.sort((a, b) => Number(amountIn ? b.amountOut - a.amountOut : a.amountIn - b.amountIn));
|
||||
if (!res.length)
|
||||
throw new Error('uniswap: cannot find path');
|
||||
return res[0];
|
||||
}
|
||||
const ROUTER_CONTRACT = createContract(UNISWAP_V2_ROUTER, undefined, UNISWAP_V2_ROUTER_CONTRACT);
|
||||
const TX_DEFAULT_OPT = {
|
||||
...uni.DEFAULT_SWAP_OPT,
|
||||
feeOnTransfer: false, // have no idea what it is
|
||||
};
|
||||
export function txData(to, input, output, path, amountIn, amountOut, opt = TX_DEFAULT_OPT) {
|
||||
opt = { ...TX_DEFAULT_OPT, ...opt };
|
||||
if (!uni.isValidUniAddr(input) || !uni.isValidUniAddr(output) || !uni.isValidEthAddr(to))
|
||||
throw new Error('Invalid address');
|
||||
if (input === 'eth' && output === 'eth')
|
||||
throw new Error('Both input and output is ETH!');
|
||||
if (input === 'eth' && path.path[0] !== uni.WETH)
|
||||
throw new Error('Input is ETH but path starts with different contract');
|
||||
if (output === 'eth' && path.path[path.path.length - 1] !== uni.WETH)
|
||||
throw new Error('Output is ETH but path ends with different contract');
|
||||
if ((amountIn && amountOut) || (!amountIn && !amountOut))
|
||||
throw new Error('uniswap.txData: provide only one amount');
|
||||
if (amountOut && opt.feeOnTransfer)
|
||||
throw new Error('Exact output + feeOnTransfer is impossible');
|
||||
const method = ('swap' +
|
||||
(amountIn ? 'Exact' : '') +
|
||||
(input === 'eth' ? 'ETH' : 'Tokens') +
|
||||
'For' +
|
||||
(amountOut ? 'Exact' : '') +
|
||||
(output === 'eth' ? 'ETH' : 'Tokens') +
|
||||
(opt.feeOnTransfer ? 'SupportingFeeOnTransferTokens' : ''));
|
||||
if (!(method in ROUTER_CONTRACT))
|
||||
throw new Error('Invalid method');
|
||||
const deadline = opt.deadline ? opt.deadline : Math.floor(Date.now() / 1000) + opt.ttl;
|
||||
const amountInMax = uni.addPercent(path.amountIn, opt.slippagePercent);
|
||||
const amountOutMin = uni.addPercent(path.amountOut, -opt.slippagePercent);
|
||||
// TODO: remove any
|
||||
const data = ROUTER_CONTRACT[method].encodeInput({
|
||||
amountInMax,
|
||||
amountOutMin,
|
||||
amountIn,
|
||||
amountOut,
|
||||
to,
|
||||
deadline,
|
||||
path: path.path,
|
||||
});
|
||||
const amount = amountIn ? amountIn : amountInMax;
|
||||
const value = input === 'eth' ? amount : BigInt(0);
|
||||
const allowance = input === 'eth' ? undefined : { token: input, amount };
|
||||
return { to: UNISWAP_V2_ROUTER_CONTRACT, value, data, allowance };
|
||||
}
|
||||
// Here goes Exchange API. Everything above is SDK. Supports almost everything from official sdk except liquidity stuff.
|
||||
export default class UniswapV2 extends uni.UniswapAbstract {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.name = 'Uniswap V2';
|
||||
this.contract = UNISWAP_V2_ROUTER_CONTRACT;
|
||||
}
|
||||
bestPath(fromCoin, toCoin, inputAmount) {
|
||||
return bestPath(this.net, fromCoin, toCoin, inputAmount);
|
||||
}
|
||||
txData(toAddress, fromCoin, toCoin, path, inputAmount, outputAmount, opt = uni.DEFAULT_SWAP_OPT) {
|
||||
return txData(toAddress, fromCoin, toCoin, path, inputAmount, outputAmount, {
|
||||
...TX_DEFAULT_OPT,
|
||||
...opt,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=uniswap-v2.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v2.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
36
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.d.ts
generated
vendored
Executable file
36
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.d.ts
generated
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
import * as uni from './uniswap-common.ts';
|
||||
export declare const Fee: Record<string, number>;
|
||||
type Route = {
|
||||
path?: Uint8Array;
|
||||
fee?: number;
|
||||
amountIn?: bigint;
|
||||
amountOut?: bigint;
|
||||
p?: any;
|
||||
};
|
||||
export type TxOpt = {
|
||||
slippagePercent: number;
|
||||
ttl: number;
|
||||
sqrtPriceLimitX96?: bigint;
|
||||
deadline?: number;
|
||||
fee?: {
|
||||
fee: number;
|
||||
to: string;
|
||||
};
|
||||
};
|
||||
export declare function txData(to: string, input: string, output: string, route: Route, amountIn?: bigint, amountOut?: bigint, opt?: TxOpt): {
|
||||
to: string;
|
||||
value: bigint;
|
||||
data: Uint8Array;
|
||||
allowance: {
|
||||
token: string;
|
||||
amount: bigint;
|
||||
} | undefined;
|
||||
};
|
||||
export default class UniswapV3 extends uni.UniswapAbstract {
|
||||
name: string;
|
||||
contract: string;
|
||||
bestPath(fromCoin: string, toCoin: string, inputAmount: bigint): Promise<Route>;
|
||||
txData(toAddress: string, fromCoin: string, toCoin: string, path: any, inputAmount?: bigint, outputAmount?: bigint, opt?: uni.SwapOpt): any;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=uniswap-v3.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"uniswap-v3.d.ts","sourceRoot":"","sources":["../../src/net/uniswap-v3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAiD3C,eAAO,MAAM,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAItC,CAAC;AAEF,KAAK,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC;AAoDjG,MAAM,MAAM,KAAK,GAAG;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC,CAAC;AAEF,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,GAAG,GAAE,KAA4B,GAChC;IACD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EACL;QACE,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,GACD,SAAS,CAAC;CACf,CAoEA;AAGD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,GAAG,CAAC,eAAe;IACxD,IAAI,SAAgB;IACpB,QAAQ,EAAE,MAAM,CAA8B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAG/E,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,GAAG,GAAE,GAAG,CAAC,OAA8B,GACtC,GAAG;CAMP"}
|
||||
176
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.js
generated
vendored
Executable file
176
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.js
generated
vendored
Executable file
@@ -0,0 +1,176 @@
|
||||
import { concatBytes } from '@noble/hashes/utils';
|
||||
import { createContract } from "../abi/decoder.js";
|
||||
import { default as UNISWAP_V3_ROUTER, UNISWAP_V3_ROUTER_CONTRACT } from "../abi/uniswap-v3.js";
|
||||
import { ethHex } from "../utils.js";
|
||||
import * as uni from "./uniswap-common.js";
|
||||
const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
|
||||
const QUOTER_ADDRESS = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6';
|
||||
const QUOTER_ABI = [
|
||||
{
|
||||
type: 'function',
|
||||
name: 'quoteExactInput',
|
||||
inputs: [
|
||||
{ name: 'path', type: 'bytes' },
|
||||
{ name: 'amountIn', type: 'uint256' },
|
||||
],
|
||||
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
||||
},
|
||||
{
|
||||
type: 'function',
|
||||
name: 'quoteExactInputSingle',
|
||||
inputs: [
|
||||
{ name: 'tokenIn', type: 'address' },
|
||||
{ name: 'tokenOut', type: 'address' },
|
||||
{ name: 'fee', type: 'uint24' },
|
||||
{ name: 'amountIn', type: 'uint256' },
|
||||
{ name: 'sqrtPriceLimitX96', type: 'uint160' },
|
||||
],
|
||||
outputs: [{ name: 'amountOut', type: 'uint256' }],
|
||||
},
|
||||
{
|
||||
type: 'function',
|
||||
name: 'quoteExactOutput',
|
||||
inputs: [
|
||||
{ name: 'path', type: 'bytes' },
|
||||
{ name: 'amountOut', type: 'uint256' },
|
||||
],
|
||||
outputs: [{ name: 'amountIn', type: 'uint256' }],
|
||||
},
|
||||
{
|
||||
type: 'function',
|
||||
name: 'quoteExactOutputSingle',
|
||||
inputs: [
|
||||
{ name: 'tokenIn', type: 'address' },
|
||||
{ name: 'tokenOut', type: 'address' },
|
||||
{ name: 'fee', type: 'uint24' },
|
||||
{ name: 'amountOut', type: 'uint256' },
|
||||
{ name: 'sqrtPriceLimitX96', type: 'uint160' },
|
||||
],
|
||||
outputs: [{ name: 'amountIn', type: 'uint256' }],
|
||||
},
|
||||
];
|
||||
export const Fee = {
|
||||
LOW: 500,
|
||||
MEDIUM: 3000,
|
||||
HIGH: 10000,
|
||||
};
|
||||
function basePaths(a, b, exactOutput = false) {
|
||||
let res = [];
|
||||
for (let fee in Fee)
|
||||
res.push({ fee: Fee[fee], p: [a, b] });
|
||||
const wA = uni.wrapContract(a);
|
||||
const wB = uni.wrapContract(b);
|
||||
const BASES = uni.COMMON_BASES.filter((c) => c && c.contract && c.contract !== wA && c.contract !== wB);
|
||||
const packFee = (n) => Fee[n].toString(16).padStart(6, '0');
|
||||
for (let c of BASES) {
|
||||
for (let fee1 in Fee) {
|
||||
for (let fee2 in Fee) {
|
||||
let path = [wA, packFee(fee1), c.contract, packFee(fee2), wB].map((i) => ethHex.decode(i));
|
||||
if (exactOutput)
|
||||
path = path.reverse();
|
||||
res.push({ path: concatBytes(...path) });
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
async function bestPath(net, a, b, amountIn, amountOut) {
|
||||
if ((amountIn && amountOut) || (!amountIn && !amountOut))
|
||||
throw new Error('uniswapV3.bestPath: provide only one amount');
|
||||
const quoter = createContract(QUOTER_ABI, net, QUOTER_ADDRESS);
|
||||
let paths = basePaths(a, b, !!amountOut);
|
||||
for (let i of paths) {
|
||||
if (!i.path && !i.fee)
|
||||
continue;
|
||||
const opt = { ...i, tokenIn: a, tokenOut: b, amountIn, amountOut, sqrtPriceLimitX96: 0 };
|
||||
const method = 'quoteExact' + (amountIn ? 'Input' : 'Output') + (i.path ? '' : 'Single');
|
||||
// TODO: remove any
|
||||
i[amountIn ? 'amountOut' : 'amountIn'] = quoter[method].call(opt);
|
||||
}
|
||||
paths = (await uni.awaitDeep(paths, true));
|
||||
paths = paths.filter((i) => i.amountIn || i.amountOut);
|
||||
paths.sort((a, b) => Number(amountIn ? b.amountOut - a.amountOut : a.amountIn - b.amountIn));
|
||||
if (!paths.length)
|
||||
throw new Error('uniswap: cannot find path');
|
||||
return paths[0];
|
||||
}
|
||||
const ROUTER_CONTRACT = createContract(UNISWAP_V3_ROUTER, undefined, UNISWAP_V3_ROUTER_CONTRACT);
|
||||
export function txData(to, input, output, route, amountIn, amountOut, opt = uni.DEFAULT_SWAP_OPT) {
|
||||
opt = { ...uni.DEFAULT_SWAP_OPT, ...opt };
|
||||
const err = 'Uniswap v3: ';
|
||||
if (!uni.isValidUniAddr(input))
|
||||
throw new Error(err + 'invalid input address');
|
||||
if (!uni.isValidUniAddr(output))
|
||||
throw new Error(err + 'invalid output address');
|
||||
if (!uni.isValidEthAddr(to))
|
||||
throw new Error(err + 'invalid to address');
|
||||
if (opt.fee && !uni.isValidUniAddr(opt.fee.to))
|
||||
throw new Error(err + 'invalid fee recepient addresss');
|
||||
if (input === 'eth' && output === 'eth')
|
||||
throw new Error(err + 'both input and output cannot be eth');
|
||||
if ((amountIn && amountOut) || (!amountIn && !amountOut))
|
||||
throw new Error(err + 'specify either amountIn or amountOut, but not both');
|
||||
if ((amountIn && !route.amountOut) ||
|
||||
(amountOut && !route.amountIn) ||
|
||||
(!route.fee && !route.path))
|
||||
throw new Error(err + 'invalid route');
|
||||
if (route.path && opt.sqrtPriceLimitX96)
|
||||
throw new Error(err + 'sqrtPriceLimitX96 on multi-hop trade');
|
||||
const deadline = opt.deadline || Math.floor(Date.now() / 1000);
|
||||
// flags for whether funds should be send first to the router
|
||||
const routerMustCustody = output === 'eth' || !!opt.fee;
|
||||
// TODO: remove "as bigint"
|
||||
let args = {
|
||||
...route,
|
||||
tokenIn: uni.wrapContract(input),
|
||||
tokenOut: uni.wrapContract(output),
|
||||
recipient: routerMustCustody ? ADDRESS_ZERO : to,
|
||||
deadline,
|
||||
amountIn: (amountIn || route.amountIn),
|
||||
amountOut: (amountOut || route.amountOut),
|
||||
sqrtPriceLimitX96: opt.sqrtPriceLimitX96 || BigInt(0),
|
||||
amountInMaximum: undefined,
|
||||
amountOutMinimum: undefined,
|
||||
};
|
||||
args.amountInMaximum = uni.addPercent(args.amountIn, opt.slippagePercent);
|
||||
args.amountOutMinimum = uni.addPercent(args.amountOut, -opt.slippagePercent);
|
||||
const method = ('exact' + (amountIn ? 'Input' : 'Output') + (!args.path ? 'Single' : ''));
|
||||
// TODO: remove unknown
|
||||
const calldatas = [ROUTER_CONTRACT[method].encodeInput(args)];
|
||||
if (input === 'eth' && amountOut)
|
||||
calldatas.push(ROUTER_CONTRACT['refundETH'].encodeInput());
|
||||
// unwrap
|
||||
if (routerMustCustody) {
|
||||
calldatas.push(ROUTER_CONTRACT[(output === 'eth' ? 'unwrapWETH9' : 'sweepToken') + (opt.fee ? 'WithFee' : '')].encodeInput({
|
||||
token: uni.wrapContract(output),
|
||||
amountMinimum: args.amountOutMinimum,
|
||||
recipient: to,
|
||||
feeBips: opt.fee && opt.fee.fee * 10000,
|
||||
feeRecipient: opt.fee && opt.fee.to,
|
||||
}));
|
||||
}
|
||||
const data = calldatas.length === 1 ? calldatas[0] : ROUTER_CONTRACT['multicall'].encodeInput(calldatas);
|
||||
const value = input === 'eth' ? (amountIn ? amountIn : args.amountInMaximum) : BigInt(0);
|
||||
const allowance = input !== 'eth'
|
||||
? { token: input, amount: amountIn ? amountIn : args.amountInMaximum }
|
||||
: undefined;
|
||||
return { to: UNISWAP_V3_ROUTER_CONTRACT, value, data, allowance };
|
||||
}
|
||||
// Here goes Exchange API. Everything above is SDK.
|
||||
export default class UniswapV3 extends uni.UniswapAbstract {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.name = 'Uniswap V3';
|
||||
this.contract = UNISWAP_V3_ROUTER_CONTRACT;
|
||||
}
|
||||
bestPath(fromCoin, toCoin, inputAmount) {
|
||||
return bestPath(this.net, fromCoin, toCoin, inputAmount);
|
||||
}
|
||||
txData(toAddress, fromCoin, toCoin, path, inputAmount, outputAmount, opt = uni.DEFAULT_SWAP_OPT) {
|
||||
return txData(toAddress, fromCoin, toCoin, path, inputAmount, outputAmount, {
|
||||
...uni.DEFAULT_SWAP_OPT,
|
||||
...opt,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=uniswap-v3.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/net/uniswap-v3.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1
dev/env/node_modules/micro-eth-signer/esm/package.json
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/package.json
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{ "type": "module", "sideEffects": false }
|
||||
22
dev/env/node_modules/micro-eth-signer/esm/rlp.d.ts
generated
vendored
Executable file
22
dev/env/node_modules/micro-eth-signer/esm/rlp.d.ts
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
import * as P from 'micro-packed';
|
||||
export type RLPInput = string | number | Uint8Array | bigint | RLPInput[] | null;
|
||||
export type InternalRLP = {
|
||||
TAG: 'byte';
|
||||
data: number;
|
||||
} | {
|
||||
TAG: 'complex';
|
||||
data: {
|
||||
TAG: 'string';
|
||||
data: Uint8Array;
|
||||
} | {
|
||||
TAG: 'list';
|
||||
data: InternalRLP[];
|
||||
};
|
||||
};
|
||||
/**
|
||||
* RLP parser.
|
||||
* Real type of rlp is `Item = Uint8Array | Item[]`.
|
||||
* Strings/number encoded to Uint8Array, but not decoded back: type information is lost.
|
||||
*/
|
||||
export declare const RLP: P.CoderType<RLPInput>;
|
||||
//# sourceMappingURL=rlp.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/rlp.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/rlp.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"rlp.d.ts","sourceRoot":"","sources":["../src/rlp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAIlC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;AA2BjF,MAAM,MAAM,WAAW,GACnB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7B;IACE,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE;QAAE,GAAG,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;CAClF,CAAC;AAoBN;;;;GAIG;AACH,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAyCpC,CAAC"}
|
||||
98
dev/env/node_modules/micro-eth-signer/esm/rlp.js
generated
vendored
Executable file
98
dev/env/node_modules/micro-eth-signer/esm/rlp.js
generated
vendored
Executable file
@@ -0,0 +1,98 @@
|
||||
import { numberToVarBytesBE } from '@noble/curves/abstract/utils';
|
||||
import * as P from 'micro-packed';
|
||||
import { isBytes } from "./utils.js";
|
||||
// length: first 3 bit !== 111 ? 6 bit length : 3bit lenlen
|
||||
const RLPLength = P.wrap({
|
||||
encodeStream(w, value) {
|
||||
if (value < 56)
|
||||
return w.bits(value, 6);
|
||||
w.bits(0b111, 3);
|
||||
const length = P.U32BE.encode(value);
|
||||
let pos = 0;
|
||||
for (; pos < length.length; pos++)
|
||||
if (length[pos] !== 0)
|
||||
break;
|
||||
w.bits(4 - pos - 1, 3);
|
||||
w.bytes(length.slice(pos));
|
||||
},
|
||||
decodeStream(r) {
|
||||
const start = r.bits(3);
|
||||
if (start !== 0b111)
|
||||
return (start << 3) | r.bits(3);
|
||||
const len = r.bytes(r.bits(3) + 1);
|
||||
for (let i = 0; i < len.length; i++) {
|
||||
if (len[i])
|
||||
break;
|
||||
throw new Error('Wrong length encoding with leading zeros');
|
||||
}
|
||||
const res = P.int(len.length).decode(len);
|
||||
if (res <= 55)
|
||||
throw new Error('RLPLength: less than 55, but used multi-byte flag');
|
||||
return res;
|
||||
},
|
||||
});
|
||||
const rlpInner = P.tag(P.map(P.bits(1), { byte: 0, complex: 1 }), {
|
||||
byte: P.bits(7),
|
||||
complex: P.tag(P.map(P.bits(1), { string: 0, list: 1 }), {
|
||||
string: P.bytes(RLPLength),
|
||||
list: P.prefix(RLPLength, P.array(null, P.lazy(() => rlpInner))),
|
||||
}),
|
||||
});
|
||||
const phex = P.hex(null);
|
||||
const pstr = P.string(null);
|
||||
const empty = Uint8Array.from([]);
|
||||
/**
|
||||
* RLP parser.
|
||||
* Real type of rlp is `Item = Uint8Array | Item[]`.
|
||||
* Strings/number encoded to Uint8Array, but not decoded back: type information is lost.
|
||||
*/
|
||||
export const RLP = P.apply(rlpInner, {
|
||||
encode(from) {
|
||||
if (from.TAG === 'byte')
|
||||
return new Uint8Array([from.data]);
|
||||
if (from.TAG !== 'complex')
|
||||
throw new Error('RLP.encode: unexpected type');
|
||||
const complex = from.data;
|
||||
if (complex.TAG === 'string') {
|
||||
if (complex.data.length === 1 && complex.data[0] < 128)
|
||||
throw new Error('RLP.encode: wrong string length encoding, should use single byte mode');
|
||||
return complex.data;
|
||||
}
|
||||
if (complex.TAG === 'list')
|
||||
return complex.data.map((i) => this.encode(i));
|
||||
throw new Error('RLP.encode: unknown TAG');
|
||||
},
|
||||
decode(data) {
|
||||
if (data == null)
|
||||
return this.decode(empty);
|
||||
switch (typeof data) {
|
||||
case 'object':
|
||||
if (isBytes(data)) {
|
||||
if (data.length === 1) {
|
||||
const head = data[0];
|
||||
if (head < 128)
|
||||
return { TAG: 'byte', data: head };
|
||||
}
|
||||
return { TAG: 'complex', data: { TAG: 'string', data: data } };
|
||||
}
|
||||
if (Array.isArray(data))
|
||||
return { TAG: 'complex', data: { TAG: 'list', data: data.map((i) => this.decode(i)) } };
|
||||
throw new Error('RLP.encode: unknown type');
|
||||
case 'number':
|
||||
if (data < 0)
|
||||
throw new Error('RLP.encode: invalid integer as argument, must be unsigned');
|
||||
if (data === 0)
|
||||
return this.decode(empty);
|
||||
return this.decode(numberToVarBytesBE(data));
|
||||
case 'bigint':
|
||||
if (data < BigInt(0))
|
||||
throw new Error('RLP.encode: invalid integer as argument, must be unsigned');
|
||||
return this.decode(numberToVarBytesBE(data));
|
||||
case 'string':
|
||||
return this.decode(data.startsWith('0x') ? phex.encode(data) : pstr.encode(data));
|
||||
default:
|
||||
throw new Error('RLP.encode: unknown type');
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=rlp.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/rlp.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/rlp.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"rlp.js","sourceRoot":"","sources":["../src/rlp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,2DAA2D;AAC3D,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC;IACvB,YAAY,CAAC,CAAW,EAAE,KAAa;QACrC,IAAI,KAAK,GAAG,EAAE;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE;YAAE,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,MAAM;QAChE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,YAAY,CAAC,CAAW;QACtB,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,KAA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,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/C,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACpF;gBACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
||||
3589
dev/env/node_modules/micro-eth-signer/esm/ssz.d.ts
generated
vendored
Executable file
3589
dev/env/node_modules/micro-eth-signer/esm/ssz.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
dev/env/node_modules/micro-eth-signer/esm/ssz.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/ssz.d.ts.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1662
dev/env/node_modules/micro-eth-signer/esm/ssz.js
generated
vendored
Executable file
1662
dev/env/node_modules/micro-eth-signer/esm/ssz.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
dev/env/node_modules/micro-eth-signer/esm/ssz.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/ssz.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
293
dev/env/node_modules/micro-eth-signer/esm/tx.d.ts
generated
vendored
Executable file
293
dev/env/node_modules/micro-eth-signer/esm/tx.d.ts
generated
vendored
Executable file
@@ -0,0 +1,293 @@
|
||||
import * as P from 'micro-packed';
|
||||
export type AnyCoder = Record<string, P.Coder<any, any>>;
|
||||
export type AnyCoderStream = Record<string, P.CoderType<any>>;
|
||||
type VersionType<V extends AnyCoderStream> = {
|
||||
[K in keyof V]: {
|
||||
type: K;
|
||||
data: P.UnwrapCoder<V[K]>;
|
||||
};
|
||||
}[keyof V];
|
||||
export type TxCoder<T extends TxType> = P.UnwrapCoder<(typeof TxVersions)[T]>;
|
||||
type VRS = Partial<{
|
||||
v: bigint;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
}>;
|
||||
type YRS = Partial<{
|
||||
chainId: bigint;
|
||||
yParity: number;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
}>;
|
||||
export declare const legacySig: P.Coder<VRS, YRS>;
|
||||
type CoderOutput<F> = F extends P.Coder<any, infer T> ? T : never;
|
||||
declare const accessListItem: P.Coder<(Uint8Array | Uint8Array[])[], {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}>;
|
||||
export type AccessList = CoderOutput<typeof accessListItem>[];
|
||||
export declare const authorizationRequest: P.Coder<Uint8Array[], {
|
||||
chainId: bigint;
|
||||
address: string;
|
||||
nonce: bigint;
|
||||
}>;
|
||||
declare const authorizationItem: P.Coder<Uint8Array[], {
|
||||
chainId: bigint;
|
||||
address: string;
|
||||
nonce: bigint;
|
||||
yParity: number;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
}>;
|
||||
export type AuthorizationItem = CoderOutput<typeof authorizationItem>;
|
||||
export type AuthorizationRequest = CoderOutput<typeof authorizationRequest>;
|
||||
/**
|
||||
* Field types, matching geth. Either u64 or u256.
|
||||
*/
|
||||
declare const coders: {
|
||||
chainId: P.Coder<P.Bytes, bigint>;
|
||||
nonce: P.Coder<P.Bytes, bigint>;
|
||||
gasPrice: P.Coder<P.Bytes, bigint>;
|
||||
maxPriorityFeePerGas: P.Coder<P.Bytes, bigint>;
|
||||
maxFeePerGas: P.Coder<P.Bytes, bigint>;
|
||||
gasLimit: P.Coder<P.Bytes, bigint>;
|
||||
to: P.Coder<Uint8Array<ArrayBufferLike>, string>;
|
||||
value: P.Coder<P.Bytes, bigint>;
|
||||
data: P.Coder<Uint8Array<ArrayBufferLike>, string>;
|
||||
accessList: P.Coder<(Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>[])[][], {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[]>;
|
||||
maxFeePerBlobGas: P.Coder<P.Bytes, bigint>;
|
||||
blobVersionedHashes: P.Coder<Uint8Array<ArrayBufferLike>[], string[]>;
|
||||
yParity: P.Coder<P.Bytes, number>;
|
||||
v: P.Coder<P.Bytes, bigint>;
|
||||
r: P.Coder<P.Bytes, bigint>;
|
||||
s: P.Coder<P.Bytes, bigint>;
|
||||
authorizationList: P.Coder<Uint8Array<ArrayBufferLike>[][], {
|
||||
chainId: bigint;
|
||||
address: string;
|
||||
nonce: bigint;
|
||||
yParity: number;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
}[]>;
|
||||
};
|
||||
type Coders = typeof coders;
|
||||
type CoderName = keyof Coders;
|
||||
type OptFields<T, O> = T & Partial<O>;
|
||||
type FieldCoder<C> = P.CoderType<C> & {
|
||||
fields: CoderName[];
|
||||
optionalFields: CoderName[];
|
||||
setOfAllFields: Set<CoderName | 'type'>;
|
||||
};
|
||||
export declare function removeSig(raw: TxCoder<any>): TxCoder<any>;
|
||||
declare const legacyInternal: FieldCoder<OptFields<{
|
||||
nonce: bigint;
|
||||
gasPrice: bigint;
|
||||
gasLimit: bigint;
|
||||
to: string;
|
||||
value: bigint;
|
||||
data: string;
|
||||
}, {
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
v: bigint;
|
||||
}>>;
|
||||
type LegacyInternal = P.UnwrapCoder<typeof legacyInternal>;
|
||||
type Legacy = Omit<LegacyInternal, 'v'> & {
|
||||
chainId?: bigint;
|
||||
yParity?: number;
|
||||
};
|
||||
export declare const TxVersions: {
|
||||
legacy: FieldCoder<Legacy>;
|
||||
eip2930: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
gasPrice: bigint;
|
||||
chainId: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
eip1559: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
chainId: bigint;
|
||||
maxPriorityFeePerGas: bigint;
|
||||
maxFeePerGas: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
eip4844: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
chainId: bigint;
|
||||
maxPriorityFeePerGas: bigint;
|
||||
maxFeePerGas: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
maxFeePerBlobGas: bigint;
|
||||
blobVersionedHashes: string[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
eip7702: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
chainId: bigint;
|
||||
maxPriorityFeePerGas: bigint;
|
||||
maxFeePerGas: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
authorizationList: {
|
||||
chainId: bigint;
|
||||
address: string;
|
||||
nonce: bigint;
|
||||
yParity: number;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
}[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
};
|
||||
export declare const RawTx: P.CoderType<VersionType<{
|
||||
legacy: FieldCoder<Legacy>;
|
||||
eip2930: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
gasPrice: bigint;
|
||||
chainId: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
eip1559: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
chainId: bigint;
|
||||
maxPriorityFeePerGas: bigint;
|
||||
maxFeePerGas: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
eip4844: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
chainId: bigint;
|
||||
maxPriorityFeePerGas: bigint;
|
||||
maxFeePerGas: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
maxFeePerBlobGas: bigint;
|
||||
blobVersionedHashes: string[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
eip7702: FieldCoder<OptFields<{
|
||||
value: bigint;
|
||||
to: string;
|
||||
data: string;
|
||||
nonce: bigint;
|
||||
chainId: bigint;
|
||||
maxPriorityFeePerGas: bigint;
|
||||
maxFeePerGas: bigint;
|
||||
gasLimit: bigint;
|
||||
accessList: {
|
||||
address: string;
|
||||
storageKeys: string[];
|
||||
}[];
|
||||
authorizationList: {
|
||||
chainId: bigint;
|
||||
address: string;
|
||||
nonce: bigint;
|
||||
yParity: number;
|
||||
r: bigint;
|
||||
s: bigint;
|
||||
}[];
|
||||
}, {
|
||||
r: bigint;
|
||||
yParity: number;
|
||||
s: bigint;
|
||||
}>>;
|
||||
}>>;
|
||||
/**
|
||||
* Unchecked TX for debugging. Returns raw Uint8Array-s.
|
||||
* Handles versions - plain RLP will crash on it.
|
||||
*/
|
||||
export declare const RlpTx: P.CoderType<{
|
||||
type: string;
|
||||
data: import('./rlp.js').RLPInput;
|
||||
}>;
|
||||
export type TxType = keyof typeof TxVersions;
|
||||
type ErrObj = {
|
||||
field: string;
|
||||
error: string;
|
||||
};
|
||||
export declare class AggregatedError extends Error {
|
||||
message: string;
|
||||
errors: ErrObj[];
|
||||
constructor(message: string, errors: ErrObj[]);
|
||||
}
|
||||
export declare function validateFields(type: TxType, data: Record<string, any>, strict?: boolean, allowSignatureFields?: boolean): void;
|
||||
export declare function sortRawData(raw: TxCoder<any>): any;
|
||||
export declare function decodeLegacyV(raw: TxCoder<any>): bigint | undefined;
|
||||
export declare const __tests: any;
|
||||
export {};
|
||||
//# sourceMappingURL=tx.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/tx.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/tx.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../src/tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AASlC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACzD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAM9D,KAAK,WAAW,CAAC,CAAC,SAAS,cAAc,IAAI;KAC1C,CAAC,IAAI,MAAM,CAAC,GAAG;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE;CACvD,CAAC,MAAM,CAAC,CAAC,C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KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/C,qBAAa,eAAgB,SAAQ,KAAK;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;gBACL,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAK9C;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,MAAM,UAAO,EACb,oBAAoB,UAAO,GAC1B,IAAI,CAwCN;AAWD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAQlD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS,CAEnE;AAGD,eAAO,MAAM,OAAO,EAAE,GAA+B,CAAC"}
|
||||
509
dev/env/node_modules/micro-eth-signer/esm/tx.js
generated
vendored
Executable file
509
dev/env/node_modules/micro-eth-signer/esm/tx.js
generated
vendored
Executable file
@@ -0,0 +1,509 @@
|
||||
import * as P from 'micro-packed';
|
||||
import { addr } from "./address.js";
|
||||
import { RLP } from "./rlp.js";
|
||||
import { amounts, ethHex, isBytes, isObject } from "./utils.js";
|
||||
// Transaction parsers
|
||||
const _0n = BigInt(0);
|
||||
const createTxMap = (versions) => {
|
||||
const ent = Object.entries(versions);
|
||||
// 'legacy' => {type, ver, coder}
|
||||
const typeMap = Object.fromEntries(ent.map(([type, coder], ver) => [type, { type, ver, coder }]));
|
||||
// '0' => {type, ver, coder}
|
||||
const verMap = Object.fromEntries(ent.map(([type, coder], ver) => [ver, { type, ver, coder }]));
|
||||
return P.wrap({
|
||||
encodeStream(w, value) {
|
||||
const t = value.type;
|
||||
if (!typeMap.hasOwnProperty(t))
|
||||
throw new Error(`txVersion: wrong type=${t}`);
|
||||
const curr = typeMap[t];
|
||||
if (t !== 'legacy')
|
||||
w.byte(curr.ver);
|
||||
curr.coder.encodeStream(w, value.data);
|
||||
},
|
||||
decodeStream(r) {
|
||||
const v = r.byte(true);
|
||||
if (v === 0xff)
|
||||
throw new Error('reserved version 0xff');
|
||||
// TODO: version=0 is legacy, but it is never wrapped in test vectors
|
||||
if (v === 0x00)
|
||||
throw new Error('version=0 unsupported');
|
||||
if (0 <= v && v <= 0x7f) {
|
||||
if (!verMap.hasOwnProperty(v.toString()))
|
||||
throw new Error(`wrong version=${v}`);
|
||||
const curr = verMap[v];
|
||||
r.byte(false); // skip first byte
|
||||
const d = curr.coder.decodeStream(r);
|
||||
return { type: curr.type, data: d };
|
||||
}
|
||||
return { type: 'legacy', data: typeMap.legacy.coder.decodeStream(r) };
|
||||
},
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Static struct could have been extracted into micro-packed, but we need a specific behavior:
|
||||
* - optional fields maybe either all present or all absent, enforced by type
|
||||
* - optional fields change the length of underlying array
|
||||
*/
|
||||
const isOptBig = (a) => a === undefined || typeof a === 'bigint';
|
||||
const isNullOr0 = (a) => a === undefined || a === BigInt(0);
|
||||
function assertYParityValid(elm) {
|
||||
// TODO: is this correct? elm = 0 default?
|
||||
if (elm === undefined)
|
||||
elm = 0;
|
||||
if (elm !== 0 && elm !== 1)
|
||||
throw new Error(`yParity wrong value=${elm} (${typeof elm})`);
|
||||
}
|
||||
// We don't know chainId when specific field coded yet.
|
||||
const addrCoder = ethHex;
|
||||
// Bytes32: VersionedHash, AccessListKey
|
||||
function ensure32(b) {
|
||||
if (!isBytes(b) || b.length !== 32)
|
||||
throw new Error('expected 32 bytes');
|
||||
return b;
|
||||
}
|
||||
const Bytes32 = {
|
||||
encode: (from) => ethHex.encode(ensure32(from)),
|
||||
decode: (to) => ensure32(ethHex.decode(to)),
|
||||
};
|
||||
// Process v as (chainId, yParity) pair. Ethers.js-inspired logic:
|
||||
// - v=27/28 -> no chainId (pre eip155)
|
||||
// - r & s == 0 -> v = chainId
|
||||
// Non-standard, but there is no other way to save chainId for unsignedTx.
|
||||
// Case: unsigned tx for cold wallet for different chains, like mainnet & testnet.
|
||||
// - otherwise v = yParity + 2*chainId + 35
|
||||
// - allows to keep legacy logic here, instead of copying to Transaction
|
||||
export const legacySig = {
|
||||
encode: (data) => {
|
||||
const { v, r, s } = data;
|
||||
if (v === undefined)
|
||||
return { chainId: undefined };
|
||||
// TODO: handle (invalid?) negative v
|
||||
if (typeof v !== 'bigint')
|
||||
throw new Error(`invalid v type=${typeof v}`);
|
||||
if ((r === undefined && s === undefined) || (r === _0n && s === _0n))
|
||||
return { chainId: v };
|
||||
if (v === BigInt(27))
|
||||
return { yParity: 0, chainId: undefined, r, s };
|
||||
if (v === BigInt(28))
|
||||
return { yParity: 1, chainId: undefined, r, s };
|
||||
if (v < BigInt(35))
|
||||
throw new Error(`wrong v=${v}`);
|
||||
const v2 = v - BigInt(35);
|
||||
return { chainId: v2 >> BigInt(1), yParity: Number(v2 & BigInt(1)), r, s };
|
||||
},
|
||||
decode: (data) => {
|
||||
aobj(data);
|
||||
const { chainId, yParity, r, s } = data;
|
||||
if (!isOptBig(chainId))
|
||||
throw new Error(`wrong chainId type=${typeof chainId}`);
|
||||
if (!isOptBig(r))
|
||||
throw new Error(`wrong r type=${typeof r}`);
|
||||
if (!isOptBig(s))
|
||||
throw new Error(`wrong s type=${typeof s}`);
|
||||
if (yParity !== undefined && typeof yParity !== 'number')
|
||||
throw new Error(`wrong yParity type=${typeof chainId}`);
|
||||
if (yParity === undefined) {
|
||||
if (chainId !== undefined) {
|
||||
if ((r !== undefined && r !== _0n) || (s !== undefined && s !== _0n))
|
||||
throw new Error(`wrong unsigned legacy r=${r} s=${s}`);
|
||||
return { v: chainId, r: _0n, s: _0n };
|
||||
}
|
||||
// no parity, chainId, but r, s exists
|
||||
if ((r !== undefined && r !== _0n) || (s !== undefined && s !== _0n))
|
||||
throw new Error(`wrong unsigned legacy r=${r} s=${s}`);
|
||||
return {};
|
||||
}
|
||||
// parity exists, which means r & s should exist too!
|
||||
if (isNullOr0(r) || isNullOr0(s))
|
||||
throw new Error(`wrong unsigned legacy r=${r} s=${s}`);
|
||||
assertYParityValid(yParity);
|
||||
const v = chainId !== undefined
|
||||
? BigInt(yParity) + (chainId * BigInt(2) + BigInt(35))
|
||||
: BigInt(yParity) + BigInt(27);
|
||||
return { v, r, s };
|
||||
},
|
||||
};
|
||||
const U64BE = P.coders.reverse(P.bigint(8, false, false, false));
|
||||
const U256BE = P.coders.reverse(P.bigint(32, false, false, false));
|
||||
// Small coder utils
|
||||
// TODO: seems generic enought for packed? or RLP (seems useful for structured encoding/decoding of RLP stuff)
|
||||
// Basic array coder
|
||||
const array = (coder) => ({
|
||||
encode(from) {
|
||||
if (!Array.isArray(from))
|
||||
throw new Error('expected array');
|
||||
return from.map((i) => coder.encode(i));
|
||||
},
|
||||
decode(to) {
|
||||
if (!Array.isArray(to))
|
||||
throw new Error('expected array');
|
||||
return to.map((i) => coder.decode(i));
|
||||
},
|
||||
});
|
||||
// tuple -> struct
|
||||
const struct = (fields) => ({
|
||||
encode(from) {
|
||||
if (!Array.isArray(from))
|
||||
throw new Error('expected array');
|
||||
const fNames = Object.keys(fields);
|
||||
if (from.length !== fNames.length)
|
||||
throw new Error('wrong array length');
|
||||
return Object.fromEntries(fNames.map((f, i) => [f, fields[f].encode(from[i])]));
|
||||
},
|
||||
decode(to) {
|
||||
const fNames = Object.keys(fields);
|
||||
if (!isObject(to))
|
||||
throw new Error('wrong struct object');
|
||||
return fNames.map((i) => fields[i].decode(to[i]));
|
||||
},
|
||||
});
|
||||
// U256BE in geth. But it is either 0 or 1. TODO: is this good enough?
|
||||
const yParityCoder = P.coders.reverse(P.validate(P.int(1, false, false, false), (elm) => {
|
||||
assertYParityValid(elm);
|
||||
return elm;
|
||||
}));
|
||||
const accessListItem = struct({ address: addrCoder, storageKeys: array(Bytes32) });
|
||||
export const authorizationRequest = struct({
|
||||
chainId: U256BE,
|
||||
address: addrCoder,
|
||||
nonce: U64BE,
|
||||
});
|
||||
// [chain_id, address, nonce, y_parity, r, s]
|
||||
const authorizationItem = struct({
|
||||
chainId: U256BE,
|
||||
address: addrCoder,
|
||||
nonce: U64BE,
|
||||
yParity: yParityCoder,
|
||||
r: U256BE,
|
||||
s: U256BE,
|
||||
});
|
||||
/**
|
||||
* Field types, matching geth. Either u64 or u256.
|
||||
*/
|
||||
const coders = {
|
||||
chainId: U256BE, // Can fit into u64 (curr max is 0x57a238f93bf), but geth uses bigint
|
||||
nonce: U64BE,
|
||||
gasPrice: U256BE,
|
||||
maxPriorityFeePerGas: U256BE,
|
||||
maxFeePerGas: U256BE,
|
||||
gasLimit: U64BE,
|
||||
to: addrCoder,
|
||||
value: U256BE, // "Decimal" coder can be used, but it's harder to work with
|
||||
data: ethHex,
|
||||
accessList: array(accessListItem),
|
||||
maxFeePerBlobGas: U256BE,
|
||||
blobVersionedHashes: array(Bytes32),
|
||||
yParity: yParityCoder,
|
||||
v: U256BE,
|
||||
r: U256BE,
|
||||
s: U256BE,
|
||||
authorizationList: array(authorizationItem),
|
||||
};
|
||||
const signatureFields = new Set(['v', 'yParity', 'r', 's']);
|
||||
// Mutates raw. Make sure to copy it in advance
|
||||
export function removeSig(raw) {
|
||||
signatureFields.forEach((k) => {
|
||||
delete raw[k];
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
/**
|
||||
* Defines RLP transaction with fields taken from `coders`.
|
||||
* @example
|
||||
* const tx = txStruct(['nonce', 'gasPrice', 'value'] as const, ['v', 'r', 's'] as const)
|
||||
* tx.nonce.decode(...);
|
||||
*/
|
||||
const txStruct = (reqf, optf) => {
|
||||
const allFields = reqf.concat(optf);
|
||||
// Check that all fields have known coders
|
||||
allFields.forEach((f) => {
|
||||
if (!coders.hasOwnProperty(f))
|
||||
throw new Error(`coder for field ${f} is not defined`);
|
||||
});
|
||||
const reqS = struct(Object.fromEntries(reqf.map((i) => [i, coders[i]])));
|
||||
const allS = struct(Object.fromEntries(allFields.map((i) => [i, coders[i]])));
|
||||
// e.g. eip1559 txs have valid lengths of 9 or 12 (unsigned / signed)
|
||||
const reql = reqf.length;
|
||||
const optl = reql + optf.length;
|
||||
const optFieldAt = (i) => reql + i;
|
||||
const isEmpty = (item) => item.length === 0;
|
||||
// TX is a bunch of fields in specific order. Field like nonce must always be at the same index.
|
||||
// We walk through all indexes in proper order.
|
||||
const fcoder = P.wrap({
|
||||
encodeStream(w, raw) {
|
||||
// If at least one optional key is present, we add whole optional block
|
||||
const hasOptional = optf.some((f) => raw.hasOwnProperty(f));
|
||||
const sCoder = hasOptional ? allS : reqS;
|
||||
RLP.encodeStream(w, sCoder.decode(raw));
|
||||
},
|
||||
decodeStream(r) {
|
||||
const decoded = RLP.decodeStream(r);
|
||||
if (!Array.isArray(decoded))
|
||||
throw new Error('txStruct: expected array from inner coder');
|
||||
const length = decoded.length;
|
||||
if (length !== reql && length !== optl)
|
||||
throw new Error(`txStruct: wrong inner length=${length}`);
|
||||
const sCoder = length === optl ? allS : reqS;
|
||||
if (length === optl && optf.every((_, i) => isEmpty(decoded[optFieldAt(i)])))
|
||||
throw new Error('all optional fields empty');
|
||||
// @ts-ignore TODO: fix type (there can be null in RLP)
|
||||
return sCoder.encode(decoded);
|
||||
},
|
||||
});
|
||||
fcoder.fields = reqf;
|
||||
fcoder.optionalFields = optf;
|
||||
fcoder.setOfAllFields = new Set(allFields.concat(['type']));
|
||||
return fcoder;
|
||||
};
|
||||
// prettier-ignore
|
||||
const legacyInternal = txStruct([
|
||||
'nonce', 'gasPrice', 'gasLimit', 'to', 'value', 'data'
|
||||
], ['v', 'r', 's']);
|
||||
const legacy = (() => {
|
||||
const res = P.apply(legacyInternal, {
|
||||
decode: (data) => Object.assign({}, data, legacySig.decode(data)),
|
||||
encode: (data) => {
|
||||
const res = Object.assign({}, data);
|
||||
res.chainId = undefined;
|
||||
if (data.v) {
|
||||
const newV = legacySig.encode(data);
|
||||
removeSig(res);
|
||||
Object.assign(res, newV);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
});
|
||||
res.fields = legacyInternal.fields.concat(['chainId']);
|
||||
// v, r, s -> yParity, r, s
|
||||
// TODO: what about chainId?
|
||||
res.optionalFields = ['yParity', 'r', 's'];
|
||||
res.setOfAllFields = new Set(res.fields.concat(res.optionalFields, ['type']));
|
||||
return res;
|
||||
})();
|
||||
// prettier-ignore
|
||||
const eip2930 = txStruct([
|
||||
'chainId', 'nonce', 'gasPrice', 'gasLimit', 'to', 'value', 'data', 'accessList'
|
||||
], ['yParity', 'r', 's']);
|
||||
// prettier-ignore
|
||||
const eip1559 = txStruct([
|
||||
'chainId', 'nonce', 'maxPriorityFeePerGas', 'maxFeePerGas', 'gasLimit', 'to', 'value', 'data', 'accessList'
|
||||
], ['yParity', 'r', 's']);
|
||||
// prettier-ignore
|
||||
const eip4844 = txStruct([
|
||||
'chainId', 'nonce', 'maxPriorityFeePerGas', 'maxFeePerGas', 'gasLimit', 'to', 'value', 'data', 'accessList',
|
||||
'maxFeePerBlobGas', 'blobVersionedHashes'
|
||||
], ['yParity', 'r', 's']);
|
||||
// prettier-ignore
|
||||
const eip7702 = txStruct([
|
||||
'chainId', 'nonce', 'maxPriorityFeePerGas', 'maxFeePerGas', 'gasLimit', 'to', 'value', 'data', 'accessList',
|
||||
'authorizationList'
|
||||
], ['yParity', 'r', 's']);
|
||||
export const TxVersions = {
|
||||
legacy, // 0x00 (kinda)
|
||||
eip2930, // 0x01
|
||||
eip1559, // 0x02
|
||||
eip4844, // 0x03
|
||||
eip7702, // 0x04
|
||||
};
|
||||
export const RawTx = P.apply(createTxMap(TxVersions), {
|
||||
// NOTE: we apply checksum to addresses here, since chainId is not available inside coders
|
||||
// By construction 'to' field is decoded before anything about chainId is known
|
||||
encode: (data) => {
|
||||
data.data.to = addr.addChecksum(data.data.to, true);
|
||||
if (data.type !== 'legacy' && data.data.accessList) {
|
||||
for (const item of data.data.accessList) {
|
||||
item.address = addr.addChecksum(item.address);
|
||||
}
|
||||
}
|
||||
if (data.type === 'eip7702' && data.data.authorizationList) {
|
||||
for (const item of data.data.authorizationList) {
|
||||
item.address = addr.addChecksum(item.address);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
// Nothing to check here, is validated in validator
|
||||
decode: (data) => data,
|
||||
});
|
||||
/**
|
||||
* Unchecked TX for debugging. Returns raw Uint8Array-s.
|
||||
* Handles versions - plain RLP will crash on it.
|
||||
*/
|
||||
export const RlpTx = createTxMap(Object.fromEntries(Object.keys(TxVersions).map((k) => [k, RLP])));
|
||||
// prettier-ignore
|
||||
// Basically all numbers. Can be useful if we decide to do converter from hex here
|
||||
// const knownFieldsNoLeading0 = [
|
||||
// 'nonce', 'maxPriorityFeePerGas', 'maxFeePerGas', 'gasLimit', 'value', 'yParity', 'r', 's'
|
||||
// ] as const;
|
||||
function abig(val) {
|
||||
if (typeof val !== 'bigint')
|
||||
throw new Error('value must be bigint');
|
||||
}
|
||||
function aobj(val) {
|
||||
if (typeof val !== 'object' || val == null)
|
||||
throw new Error('object expected');
|
||||
}
|
||||
function minmax(val, min, max, err) {
|
||||
if (!err)
|
||||
err = `>= ${min} and <= ${max}`;
|
||||
if (Number.isNaN(val) || val < min || val > max)
|
||||
throw new Error(`must be ${err}, not ${val}`);
|
||||
}
|
||||
// NOTE: non-strict validators can be removed (RawTx will handle that), but errors will be less user-friendly.
|
||||
// On other hand, we twice per sig because tx is immutable
|
||||
// data passed for composite checks (gasLimit * maxFeePerGas overflow and stuff) [not implemented yet]
|
||||
const validators = {
|
||||
nonce(num, { strict }) {
|
||||
abig(num);
|
||||
if (strict)
|
||||
minmax(num, _0n, amounts.maxNonce);
|
||||
else
|
||||
minmax(BigInt(num), _0n, BigInt(Number.MAX_SAFE_INTEGER)); // amounts.maxUint64
|
||||
},
|
||||
maxFeePerGas(num, { strict }) {
|
||||
abig(num);
|
||||
if (strict)
|
||||
minmax(num, BigInt(1), amounts.maxGasPrice, '>= 1 wei and < 10000 gwei');
|
||||
else
|
||||
minmax(num, _0n, amounts.maxUint64);
|
||||
},
|
||||
maxPriorityFeePerGas(num, { strict, data }) {
|
||||
abig(num);
|
||||
if (strict)
|
||||
minmax(num, _0n, amounts.maxGasPrice, '>= 1 wei and < 10000 gwei');
|
||||
else
|
||||
minmax(num, _0n, amounts.maxUint64, '>= 1 wei and < 10000 gwei');
|
||||
if (strict && data && typeof data.maxFeePerGas === 'bigint' && data.maxFeePerGas < num) {
|
||||
throw new Error(`cannot be bigger than maxFeePerGas=${data.maxFeePerGas}`);
|
||||
}
|
||||
},
|
||||
gasLimit(num, { strict }) {
|
||||
abig(num);
|
||||
if (strict)
|
||||
minmax(num, amounts.minGasLimit, amounts.maxGasLimit);
|
||||
else
|
||||
minmax(num, _0n, amounts.maxUint64);
|
||||
},
|
||||
to(address, { strict, data }) {
|
||||
if (!addr.isValid(address, true))
|
||||
throw new Error('address checksum does not match');
|
||||
if (strict && address === '0x' && !data.data)
|
||||
throw new Error('Empty address (0x) without contract deployment code');
|
||||
},
|
||||
value(num) {
|
||||
abig(num);
|
||||
minmax(num, _0n, amounts.maxAmount, '>= 0 and < 100M eth');
|
||||
},
|
||||
data(val, { strict, data }) {
|
||||
if (typeof val !== 'string')
|
||||
throw new Error('data must be string');
|
||||
if (strict) {
|
||||
if (val.length > amounts.maxDataSize)
|
||||
throw new Error('data is too big: ' + val.length);
|
||||
}
|
||||
// NOTE: data is hex here
|
||||
if (data.to === '0x' && val.length > 2 * amounts.maxInitDataSize)
|
||||
throw new Error(`initcode is too big: ${val.length}`);
|
||||
},
|
||||
chainId(num, { strict, type }) {
|
||||
// chainId is optional for legacy transactions
|
||||
if (type === 'legacy' && num === undefined)
|
||||
return;
|
||||
abig(num);
|
||||
if (strict)
|
||||
minmax(num, BigInt(1), amounts.maxChainId, '>= 1 and <= 2**32-1');
|
||||
},
|
||||
accessList(list) {
|
||||
// NOTE: we cannot handle this validation in coder, since it requires chainId to calculate correct checksum
|
||||
for (const { address } of list) {
|
||||
if (!addr.isValid(address))
|
||||
throw new Error('address checksum does not match');
|
||||
}
|
||||
},
|
||||
authorizationList(list, opts) {
|
||||
for (const { address, nonce, chainId } of list) {
|
||||
if (!addr.isValid(address))
|
||||
throw new Error('address checksum does not match');
|
||||
// chainId in authorization list can be zero (==allow any chain)
|
||||
abig(chainId);
|
||||
if (opts.strict)
|
||||
minmax(chainId, _0n, amounts.maxChainId, '>= 0 and <= 2**32-1');
|
||||
this.nonce(nonce, opts);
|
||||
}
|
||||
},
|
||||
};
|
||||
export class AggregatedError extends Error {
|
||||
constructor(message, errors) {
|
||||
super();
|
||||
this.message = message;
|
||||
this.errors = errors;
|
||||
}
|
||||
}
|
||||
export function validateFields(type, data, strict = true, allowSignatureFields = true) {
|
||||
aobj(data);
|
||||
if (!TxVersions.hasOwnProperty(type))
|
||||
throw new Error(`unknown tx type=${type}`);
|
||||
const txType = TxVersions[type];
|
||||
const dataFields = new Set(Object.keys(data));
|
||||
const dataHas = (field) => dataFields.has(field);
|
||||
function checkField(field) {
|
||||
if (!dataHas(field))
|
||||
return { field, error: `field "${field}" must be present for tx type=${type}` };
|
||||
const val = data[field];
|
||||
try {
|
||||
if (validators.hasOwnProperty(field))
|
||||
validators[field](val, { data, strict, type });
|
||||
if (field === 'chainId')
|
||||
return; // chainId is validated, but can't be decoded
|
||||
coders[field].decode(val); // decoding may throw an error
|
||||
}
|
||||
catch (error) {
|
||||
// No early-return: when multiple fields have error, we should show them all.
|
||||
return { field, error: error.message };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// All fields are required.
|
||||
const reqErrs = txType.fields.map(checkField);
|
||||
// Signature fields should be all present or all missing
|
||||
const optErrs = txType.optionalFields.some(dataHas) ? txType.optionalFields.map(checkField) : [];
|
||||
// Check if user data has unexpected fields
|
||||
const unexpErrs = Object.keys(data).map((field) => {
|
||||
if (!txType.setOfAllFields.has(field))
|
||||
return { field, error: `unknown field "${field}" for tx type=${type}` };
|
||||
if (!allowSignatureFields && signatureFields.has(field))
|
||||
return {
|
||||
field,
|
||||
error: `field "${field}" is sig-related and must not be user-specified`,
|
||||
};
|
||||
return;
|
||||
});
|
||||
const errors = reqErrs
|
||||
.concat(optErrs, unexpErrs)
|
||||
.filter((val) => val !== undefined);
|
||||
if (errors.length > 0)
|
||||
throw new AggregatedError('fields had validation errors', errors);
|
||||
}
|
||||
// prettier-ignore
|
||||
const sortedFieldOrder = [
|
||||
'to', 'value', 'nonce',
|
||||
'maxFeePerGas', 'maxFeePerBlobGas', 'maxPriorityFeePerGas', 'gasPrice', 'gasLimit',
|
||||
'accessList', 'authorizationList', 'blobVersionedHashes', 'chainId', 'data', 'type',
|
||||
'r', 's', 'yParity', 'v'
|
||||
];
|
||||
// TODO: remove any
|
||||
export function sortRawData(raw) {
|
||||
const sortedRaw = {};
|
||||
sortedFieldOrder
|
||||
.filter((field) => raw.hasOwnProperty(field))
|
||||
.forEach((field) => {
|
||||
sortedRaw[field] = raw[field];
|
||||
});
|
||||
return sortedRaw;
|
||||
}
|
||||
export function decodeLegacyV(raw) {
|
||||
return legacySig.decode(raw).v;
|
||||
}
|
||||
// NOTE: for tests only, don't use
|
||||
export const __tests = { legacySig, TxVersions };
|
||||
//# sourceMappingURL=tx.js.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/tx.js.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/tx.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
78
dev/env/node_modules/micro-eth-signer/esm/typed-data.d.ts
generated
vendored
Executable file
78
dev/env/node_modules/micro-eth-signer/esm/typed-data.d.ts
generated
vendored
Executable file
@@ -0,0 +1,78 @@
|
||||
import type { GetType as AbiGetType } from './abi/decoder.ts';
|
||||
export type Hex = string | Uint8Array;
|
||||
export interface TypedSigner<T> {
|
||||
_getHash: (message: T) => string;
|
||||
sign(message: T, privateKey: Hex, extraEntropy?: boolean | Uint8Array): string;
|
||||
recoverPublicKey(signature: string, message: T): string;
|
||||
verify(signature: string, message: T, address: string): boolean;
|
||||
}
|
||||
export declare const personal: TypedSigner<string | Uint8Array>;
|
||||
export type EIP712Component = {
|
||||
name: string;
|
||||
type: string;
|
||||
};
|
||||
export type EIP712Types = Record<string, readonly EIP712Component[]>;
|
||||
type ProcessType<T extends string, Types extends EIP712Types> = T extends `${infer Base}[]${infer Rest}` ? ProcessType<`${Base}${Rest}`, Types>[] : T extends `${infer Base}[${number}]${infer Rest}` ? ProcessType<`${Base}${Rest}`, Types>[] : T extends keyof Types ? GetType<Types, T> | undefined : AbiGetType<T>;
|
||||
export type GetType<Types extends EIP712Types, K extends keyof Types & string> = {
|
||||
[C in Types[K][number] as C['name']]: ProcessType<C['type'], Types>;
|
||||
};
|
||||
type Key<T extends EIP712Types> = keyof T & string;
|
||||
export declare function encoder<T extends EIP712Types>(types: T, domain: GetType<T, 'EIP712Domain'>): {
|
||||
encodeData: <K extends Key<T>>(type: K, message: GetType<T, K>) => string;
|
||||
structHash: <K extends Key<T>>(type: K, message: GetType<T, K>) => string;
|
||||
_getHash: <K extends Key<T>>(primaryType: K, message: GetType<T, K>) => string;
|
||||
sign: <K extends Key<T>>(primaryType: K, message: GetType<T, K>, privateKey: Hex, extraEntropy?: boolean | Uint8Array) => string;
|
||||
verify: <K extends Key<T>>(primaryType: K, signature: string, message: GetType<T, K>, address: string) => boolean;
|
||||
recoverPublicKey: <K extends Key<T>>(primaryType: K, signature: string, message: GetType<T, K>) => string;
|
||||
};
|
||||
export declare const EIP712Domain: readonly [{
|
||||
readonly name: "name";
|
||||
readonly type: "string";
|
||||
}, {
|
||||
readonly name: "version";
|
||||
readonly type: "string";
|
||||
}, {
|
||||
readonly name: "chainId";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly name: "verifyingContract";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly name: "salt";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
export type DomainParams = typeof EIP712Domain;
|
||||
declare const domainTypes: {
|
||||
EIP712Domain: DomainParams;
|
||||
};
|
||||
export type EIP712Domain = GetType<typeof domainTypes, 'EIP712Domain'>;
|
||||
export declare function getDomainType(domain: EIP712Domain): ({
|
||||
readonly name: "name";
|
||||
readonly type: "string";
|
||||
} | {
|
||||
readonly name: "version";
|
||||
readonly type: "string";
|
||||
} | {
|
||||
readonly name: "chainId";
|
||||
readonly type: "uint256";
|
||||
} | {
|
||||
readonly name: "verifyingContract";
|
||||
readonly type: "address";
|
||||
} | {
|
||||
readonly name: "salt";
|
||||
readonly type: "bytes32";
|
||||
})[];
|
||||
export type TypedData<T extends EIP712Types, K extends Key<T>> = {
|
||||
types: T;
|
||||
primaryType: K;
|
||||
domain: GetType<T, 'EIP712Domain'>;
|
||||
message: GetType<T, K>;
|
||||
};
|
||||
export declare function encodeData<T extends EIP712Types, K extends Key<T>>(typed: TypedData<T, K>): string;
|
||||
export declare function sigHash<T extends EIP712Types, K extends Key<T>>(typed: TypedData<T, K>): string;
|
||||
export declare function signTyped<T extends EIP712Types, K extends Key<T>>(typed: TypedData<T, K>, privateKey: Hex, extraEntropy?: boolean | Uint8Array): string;
|
||||
export declare function verifyTyped<T extends EIP712Types, K extends Key<T>>(signature: string, typed: TypedData<T, K>, address: string): boolean;
|
||||
export declare function recoverPublicKeyTyped<T extends EIP712Types, K extends Key<T>>(signature: string, typed: TypedData<T, K>): string;
|
||||
export declare const _TEST: any;
|
||||
export {};
|
||||
//# sourceMappingURL=typed-data.d.ts.map
|
||||
1
dev/env/node_modules/micro-eth-signer/esm/typed-data.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/micro-eth-signer/esm/typed-data.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"typed-data.d.ts","sourceRoot":"","sources":["../src/typed-data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAM9D,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,UAAU,CAAC;AACtC,MAAM,WAAW,W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,SAAS,GAAG,CAAC,CAAC,CAAC,EAC3E,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GACrB,MAAM,CAMR;AAGD,eAAO,MAAM,KAAK,EAAE,GAAuE,CAAC"}
|
||||
294
dev/env/node_modules/micro-eth-signer/esm/typed-data.js
generated
vendored
Executable file
294
dev/env/node_modules/micro-eth-signer/esm/typed-data.js
generated
vendored
Executable file
@@ -0,0 +1,294 @@
|
||||
import { keccak_256 } from '@noble/hashes/sha3';
|
||||
import { concatBytes, hexToBytes, utf8ToBytes } from '@noble/hashes/utils';
|
||||
import { mapComponent } from "./abi/decoder.js";
|
||||
import { addr } from "./address.js";
|
||||
import { add0x, astr, ethHex, initSig, isObject, sign, strip0x, verify } from "./utils.js";
|
||||
// 0x19 <1 byte version> <version specific data> <data to sign>.
|
||||
// VERSIONS:
|
||||
// - 0x19 <0x00> <intended validator address> <data to sign>
|
||||
// - 0x19 <0x01> domainSeparator hashStruct(message)
|
||||
// - 0x19 <0x45 (E)> <thereum Signed Message:\n" + len(message)> <data to sign>
|
||||
function getSigner(version, msgFn) {
|
||||
if (version < 0 || version >= 256 || !Number.isSafeInteger(version))
|
||||
throw new Error('Wrong version byte');
|
||||
// bytes32 hash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), msg.value, nonce, payload));
|
||||
const getHash = (message) => keccak_256(concatBytes(new Uint8Array([0x19, version]), msgFn(message)));
|
||||
// TODO: 'v' can contain non-undefined chainId, but not sure if it is used. If used, we need to check it with EIP-712 domain
|
||||
return {
|
||||
_getHash: (message) => ethHex.encode(getHash(message)),
|
||||
sign(message, privateKey, extraEntropy = true) {
|
||||
const hash = getHash(message);
|
||||
if (typeof privateKey === 'string')
|
||||
privateKey = ethHex.decode(privateKey);
|
||||
const sig = sign(hash, privateKey, extraEntropy);
|
||||
const end = sig.recovery === 0 ? '1b' : '1c';
|
||||
return add0x(sig.toCompactHex() + end);
|
||||
},
|
||||
recoverPublicKey(signature, message) {
|
||||
astr(signature);
|
||||
const hash = getHash(message);
|
||||
signature = strip0x(signature);
|
||||
if (signature.length !== 65 * 2)
|
||||
throw new Error('invalid signature length');
|
||||
const sigh = signature.slice(0, -2);
|
||||
const end = signature.slice(-2);
|
||||
if (!['1b', '1c'].includes(end))
|
||||
throw new Error('invalid recovery bit');
|
||||
const sig = initSig(hexToBytes(sigh), end === '1b' ? 0 : 1);
|
||||
const pub = sig.recoverPublicKey(hash).toRawBytes(false);
|
||||
if (!verify(sig, hash, pub))
|
||||
throw new Error('invalid signature');
|
||||
return addr.fromPublicKey(pub);
|
||||
},
|
||||
verify(signature, message, address) {
|
||||
const recAddr = this.recoverPublicKey(signature, message);
|
||||
const low = recAddr.toLowerCase();
|
||||
const upp = recAddr.toUpperCase();
|
||||
if (address === low || address === upp)
|
||||
return true; // non-checksummed
|
||||
return recAddr === address; // checksummed
|
||||
},
|
||||
};
|
||||
}
|
||||
// EIP-191/EIP-7749: 0x19 <0x00> <intended validator address> <data to sign>
|
||||
// export const intendedValidator = getSigner(
|
||||
// 0x00,
|
||||
// ({ message, validator }: { message: Uint8Array; validator: string }) => {
|
||||
// const { data } = addr.parse(validator);
|
||||
// return concatBytes(hexToBytes(data), message);
|
||||
// }
|
||||
// );
|
||||
// EIP-191: 0x19 <0x45 (E)> <thereum Signed Message:\n" + len(message)> <data to sign>
|
||||
export const personal = getSigner(0x45, (msg) => {
|
||||
if (typeof msg === 'string')
|
||||
msg = utf8ToBytes(msg);
|
||||
return concatBytes(utf8ToBytes(`thereum Signed Message:\n${msg.length}`), msg);
|
||||
});
|
||||
// TODO: merge with abi somehow?
|
||||
function parseType(s) {
|
||||
let m = s.match(/^([^\[]+)(?:.*\[(.*?)\])?$/);
|
||||
if (!m)
|
||||
throw new Error(`parseType: wrong type: ${s}`);
|
||||
const base = m[1];
|
||||
const isArray = m[2] !== undefined;
|
||||
// TODO: check for safe integer
|
||||
const arrayLen = m[2] !== undefined && m[2] !== '' ? Number(m[2]) : undefined;
|
||||
if (arrayLen !== undefined && (!Number.isSafeInteger(arrayLen) || arrayLen.toString() !== m[2]))
|
||||
throw new Error(`parseType: wrong array length: ${s}`);
|
||||
let type = 'struct';
|
||||
if (['string', 'bytes'].includes(base))
|
||||
type = 'dynamic';
|
||||
else if (['bool', 'address'].includes(base))
|
||||
type = 'atomic';
|
||||
else if ((m = /^(u?)int([0-9]+)?$/.exec(base))) {
|
||||
const bits = m[2] ? +m[2] : 256;
|
||||
if (!Number.isSafeInteger(bits) || bits <= 0 || bits % 8 !== 0 || bits > 256)
|
||||
throw new Error('parseType: invalid numeric type');
|
||||
type = 'atomic';
|
||||
}
|
||||
else if ((m = /^bytes([0-9]{1,2})$/.exec(base))) {
|
||||
const bytes = +m[1];
|
||||
if (!bytes || bytes > 32)
|
||||
throw new Error(`parseType: wrong bytes<N=${bytes}> type`);
|
||||
type = 'atomic';
|
||||
}
|
||||
const item = s.replace(/\[[^\]]*\]$/, '');
|
||||
return { base, item, type, arrayLen, isArray };
|
||||
}
|
||||
// traverse dependency graph, find all transitive dependencies. Also, basic sanity check
|
||||
function getDependencies(types) {
|
||||
if (typeof types !== 'object' || types === null)
|
||||
throw new Error('wrong types object');
|
||||
// Collect non-basic dependencies & sanity
|
||||
const res = {};
|
||||
for (const [name, fields] of Object.entries(types)) {
|
||||
const cur = new Set(); // type may appear multiple times in struct
|
||||
for (const { type } of fields) {
|
||||
const p = parseType(type);
|
||||
if (p.type !== 'struct')
|
||||
continue; // skip basic fields
|
||||
if (p.base === name)
|
||||
continue; // self reference
|
||||
if (!types[p.base])
|
||||
throw new Error(`getDependencies: wrong struct type name=${type}`);
|
||||
cur.add(p.base);
|
||||
}
|
||||
res[name] = cur;
|
||||
}
|
||||
// This should be more efficient with toposort + cycle detection, but I've already spent too much time here
|
||||
// and for most cases there won't be a lot of types here anyway.
|
||||
for (let changed = true; changed;) {
|
||||
changed = false;
|
||||
for (const [name, curDeps] of Object.entries(res)) {
|
||||
// Map here, because curDeps will change
|
||||
const trDeps = Array.from(curDeps).map((i) => res[i]);
|
||||
for (const d of trDeps) {
|
||||
for (const td of d) {
|
||||
if (td === name || curDeps.has(td))
|
||||
continue;
|
||||
curDeps.add(td);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function getTypes(types) {
|
||||
const deps = getDependencies(types);
|
||||
const names = {};
|
||||
// Build names
|
||||
for (const type in types)
|
||||
names[type] = `${type}(${types[type].map(({ name, type }) => `${type} ${name}`).join(',')})`;
|
||||
const fullNames = {};
|
||||
for (const [name, curDeps] of Object.entries(deps)) {
|
||||
const n = [name].concat(Array.from(curDeps).sort());
|
||||
fullNames[name] = n.map((i) => names[i]).join('');
|
||||
}
|
||||
const hashes = Object.fromEntries(Object.entries(fullNames).map(([k, v]) => [k, keccak_256(v)]));
|
||||
// fields
|
||||
const fields = {};
|
||||
for (const type in types) {
|
||||
const res = new Set();
|
||||
for (const { name } of types[type]) {
|
||||
if (res.has(name))
|
||||
throw new Error(`field ${name} included multiple times in type ${type}`);
|
||||
res.add(name);
|
||||
}
|
||||
fields[type] = res;
|
||||
}
|
||||
return { names, fullNames, hashes, fields };
|
||||
}
|
||||
// This re-uses domain per multiple requests, which is based on assumption that domain is static for different requests with
|
||||
// different types. Please raise issue if you have different use case.
|
||||
export function encoder(types, domain) {
|
||||
if (!isObject(domain))
|
||||
throw Error(`wrong domain=${domain}`);
|
||||
if (!isObject(types))
|
||||
throw Error(`wrong types=${types}`);
|
||||
const info = getTypes(types);
|
||||
const encodeField = (type, data, withHash = true) => {
|
||||
const p = parseType(type);
|
||||
if (p.isArray) {
|
||||
if (!Array.isArray(data))
|
||||
throw new Error(`expected array, got: ${data}`);
|
||||
if (p.arrayLen !== undefined && data.length !== p.arrayLen)
|
||||
throw new Error(`wrong array length: expected ${p.arrayLen}, got ${data}`);
|
||||
return keccak_256(concatBytes(...data.map((i) => encodeField(p.item, i))));
|
||||
}
|
||||
if (p.type === 'struct') {
|
||||
const def = types[type];
|
||||
if (!def)
|
||||
throw new Error(`wrong type: ${type}`);
|
||||
const fieldNames = info.fields[type];
|
||||
if (!isObject(data))
|
||||
throw new Error(`encoding non-object as custom type ${type}`);
|
||||
for (const k in data)
|
||||
if (!fieldNames.has(k))
|
||||
throw new Error(`unexpected field ${k} in ${type}`);
|
||||
// TODO: use correct concatBytes (need to export from P?). This will easily crash with stackoverflow if too much fields.
|
||||
const fields = [];
|
||||
for (const { name, type } of def) {
|
||||
// This is not mentioned in spec, but used in eth-sig-util
|
||||
// Since there is no 'optional' fields inside eip712, it makes impossible to encode circular structure without arrays,
|
||||
// but seems like other project use this.
|
||||
// NOTE: this is V4 only stuff. If you need V3 behavior, please open issue.
|
||||
if (types[type] && data[name] === undefined) {
|
||||
fields.push(new Uint8Array(32));
|
||||
continue;
|
||||
}
|
||||
fields.push(encodeField(type, data[name]));
|
||||
}
|
||||
const res = concatBytes(info.hashes[p.base], ...fields);
|
||||
return withHash ? keccak_256(res) : res;
|
||||
}
|
||||
if (type === 'string' || type === 'bytes') {
|
||||
if (type === 'bytes' && typeof data === 'string')
|
||||
data = ethHex.decode(data);
|
||||
return keccak_256(data); // hashed as is!
|
||||
}
|
||||
// Type conversion is neccessary here, because we can get data from JSON (no Uint8Arrays/bigints).
|
||||
if (type.startsWith('bytes') && typeof data === 'string')
|
||||
data = ethHex.decode(data);
|
||||
if ((type.startsWith('int') || type.startsWith('uint')) && typeof data === 'string')
|
||||
data = BigInt(data);
|
||||
return mapComponent({ type }).encode(data);
|
||||
};
|
||||
const encodeData = (type, data) => {
|
||||
astr(type);
|
||||
if (!types[type])
|
||||
throw new Error(`Unknown type: ${type}`);
|
||||
if (!isObject(data))
|
||||
throw new Error('wrong data object');
|
||||
return encodeField(type, data, false);
|
||||
};
|
||||
const structHash = (type, data) => keccak_256(encodeData(type, data));
|
||||
const domainHash = structHash('EIP712Domain', domain);
|
||||
// NOTE: we cannot use Msg here, since its already parametrized and everything will break.
|
||||
const signer = getSigner(0x01, (msg) => {
|
||||
if (typeof msg.primaryType !== 'string')
|
||||
throw Error(`wrong primaryType=${msg.primaryType}`);
|
||||
if (!isObject(msg.message))
|
||||
throw Error(`wrong message=${msg.message}`);
|
||||
if (msg.primaryType === 'EIP712Domain')
|
||||
return domainHash;
|
||||
return concatBytes(domainHash, structHash(msg.primaryType, msg.message));
|
||||
});
|
||||
return {
|
||||
encodeData: (type, message) => ethHex.encode(encodeData(type, message)),
|
||||
structHash: (type, message) => ethHex.encode(structHash(type, message)),
|
||||
// Signer
|
||||
_getHash: (primaryType, message) => signer._getHash({ primaryType, message }),
|
||||
sign: (primaryType, message, privateKey, extraEntropy) => signer.sign({ primaryType, message }, privateKey, extraEntropy),
|
||||
verify: (primaryType, signature, message, address) => signer.verify(signature, { primaryType, message }, address),
|
||||
recoverPublicKey: (primaryType, signature, message) => signer.recoverPublicKey(signature, { primaryType, message }),
|
||||
};
|
||||
}
|
||||
export const EIP712Domain = [
|
||||
{ name: 'name', type: 'string' }, // the user readable name of signing domain, i.e. the name of the DApp or the protocol.
|
||||
{ name: 'version', type: 'string' }, // the current major version of the signing domain. Signatures from different versions are not compatible.
|
||||
{ name: 'chainId', type: 'uint256' }, // the EIP-155 chain id. The user-agent should refuse signing if it does not match the currently active chain.
|
||||
{ name: 'verifyingContract', type: 'address' }, // the address of the contract that will verify the signature. The user-agent may do contract specific phishing prevention.
|
||||
{ name: 'salt', type: 'bytes32' }, // an disambiguating salt for the protocol. This can be used as a domain separator of last resort.
|
||||
];
|
||||
const domainTypes = { EIP712Domain: EIP712Domain };
|
||||
// Filter unused domain fields from type
|
||||
export function getDomainType(domain) {
|
||||
return EIP712Domain.filter(({ name }) => domain[name] !== undefined);
|
||||
}
|
||||
const getTypedTypes = (typed) => ({
|
||||
EIP712Domain: getDomainType(typed.domain),
|
||||
...typed.types,
|
||||
});
|
||||
function validateTyped(t) {
|
||||
if (!isObject(t.message))
|
||||
throw new Error('wrong message');
|
||||
if (!isObject(t.domain))
|
||||
throw new Error('wrong domain');
|
||||
if (!isObject(t.types))
|
||||
throw new Error('wrong types');
|
||||
if (typeof t.primaryType !== 'string' || !t.types[t.primaryType])
|
||||
throw new Error('wrong primaryType');
|
||||
}
|
||||
export function encodeData(typed) {
|
||||
validateTyped(typed);
|
||||
return encoder(getTypedTypes(typed), typed.domain).encodeData(typed.primaryType, typed.message);
|
||||
}
|
||||
export function sigHash(typed) {
|
||||
validateTyped(typed);
|
||||
return encoder(getTypedTypes(typed), typed.domain)._getHash(typed.primaryType, typed.message);
|
||||
}
|
||||
export function signTyped(typed, privateKey, extraEntropy) {
|
||||
validateTyped(typed);
|
||||
return encoder(getTypedTypes(typed), typed.domain).sign(typed.primaryType, typed.message, privateKey, extraEntropy);
|
||||
}
|
||||
export function verifyTyped(signature, typed, address) {
|
||||
validateTyped(typed);
|
||||
return encoder(getTypedTypes(typed), typed.domain).verify(typed.primaryType, signature, typed.message, address);
|
||||
}
|
||||
export function recoverPublicKeyTyped(signature, typed) {
|
||||
return encoder(getTypedTypes(typed), typed.domain).recoverPublicKey(typed.primaryType, signature, typed.message);
|
||||
}
|
||||
// Internal methods for test purposes only
|
||||
export const _TEST = /* @__PURE__ */ { parseType, getDependencies, getTypes, encoder };
|
||||
//# sourceMappingURL=typed-data.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user