@reyaxyz/common 0.213.0 → 0.214.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -786,6 +786,107 @@
|
|
|
786
786
|
"outputs": [],
|
|
787
787
|
"stateMutability": "nonpayable"
|
|
788
788
|
},
|
|
789
|
+
{
|
|
790
|
+
"type": "function",
|
|
791
|
+
"name": "executeViaPublisher",
|
|
792
|
+
"inputs": [
|
|
793
|
+
{
|
|
794
|
+
"name": "inputs",
|
|
795
|
+
"type": "tuple",
|
|
796
|
+
"internalType": "struct PeripheryExecutionViaPublisherInputs",
|
|
797
|
+
"components": [
|
|
798
|
+
{
|
|
799
|
+
"name": "accountId",
|
|
800
|
+
"type": "uint128",
|
|
801
|
+
"internalType": "uint128"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
"name": "commands",
|
|
805
|
+
"type": "tuple[]",
|
|
806
|
+
"internalType": "struct Command[]",
|
|
807
|
+
"components": [
|
|
808
|
+
{
|
|
809
|
+
"name": "commandType",
|
|
810
|
+
"type": "uint8",
|
|
811
|
+
"internalType": "enum CommandType"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
"name": "inputs",
|
|
815
|
+
"type": "bytes",
|
|
816
|
+
"internalType": "bytes"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"name": "marketId",
|
|
820
|
+
"type": "uint128",
|
|
821
|
+
"internalType": "uint128"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"name": "exchangeId",
|
|
825
|
+
"type": "uint128",
|
|
826
|
+
"internalType": "uint128"
|
|
827
|
+
}
|
|
828
|
+
]
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"name": "sig",
|
|
832
|
+
"type": "tuple",
|
|
833
|
+
"internalType": "struct EIP712Signature",
|
|
834
|
+
"components": [
|
|
835
|
+
{
|
|
836
|
+
"name": "v",
|
|
837
|
+
"type": "uint8",
|
|
838
|
+
"internalType": "uint8"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"name": "r",
|
|
842
|
+
"type": "bytes32",
|
|
843
|
+
"internalType": "bytes32"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
"name": "s",
|
|
847
|
+
"type": "bytes32",
|
|
848
|
+
"internalType": "bytes32"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"name": "deadline",
|
|
852
|
+
"type": "uint256",
|
|
853
|
+
"internalType": "uint256"
|
|
854
|
+
}
|
|
855
|
+
]
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"name": "publisherSig",
|
|
859
|
+
"type": "tuple",
|
|
860
|
+
"internalType": "struct EIP712Signature",
|
|
861
|
+
"components": [
|
|
862
|
+
{
|
|
863
|
+
"name": "v",
|
|
864
|
+
"type": "uint8",
|
|
865
|
+
"internalType": "uint8"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
"name": "r",
|
|
869
|
+
"type": "bytes32",
|
|
870
|
+
"internalType": "bytes32"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"name": "s",
|
|
874
|
+
"type": "bytes32",
|
|
875
|
+
"internalType": "bytes32"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"name": "deadline",
|
|
879
|
+
"type": "uint256",
|
|
880
|
+
"internalType": "uint256"
|
|
881
|
+
}
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
]
|
|
885
|
+
}
|
|
886
|
+
],
|
|
887
|
+
"outputs": [],
|
|
888
|
+
"stateMutability": "nonpayable"
|
|
889
|
+
},
|
|
789
890
|
{
|
|
790
891
|
"type": "function",
|
|
791
892
|
"name": "isCommandAllowed",
|
|
@@ -12,7 +12,7 @@ exports.descale = descale;
|
|
|
12
12
|
var scale = function (tokenDecimals) {
|
|
13
13
|
return function (value) {
|
|
14
14
|
// Convert the number to a string
|
|
15
|
-
var valueStr = value.toString();
|
|
15
|
+
var valueStr = value.toString(10);
|
|
16
16
|
// Split the string into whole and fractional parts
|
|
17
17
|
// eslint-disable-next-line prefer-const
|
|
18
18
|
var _a = valueStr.split('.'), whole = _a[0], _b = _a[1], fractional = _b === void 0 ? '' : _b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"/","sources":["utils/token/utils.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAGzB,IAAM,OAAO,GAAG,UAAC,aAAqB;IAC3C,IAAM,CAAC,GAAG,UAAC,KAAa;QACtB,OAAO,MAAM,CAAC,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AANW,QAAA,OAAO,WAMlB;AAEK,IAAM,KAAK,GAAG,UAAC,aAAqB;IACzC,OAAO,UAAC,KAAa;QACnB,iCAAiC;QACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"/","sources":["utils/token/utils.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAGzB,IAAM,OAAO,GAAG,UAAC,aAAqB;IAC3C,IAAM,CAAC,GAAG,UAAC,KAAa;QACtB,OAAO,MAAM,CAAC,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AANW,QAAA,OAAO,WAMlB;AAEK,IAAM,KAAK,GAAG,UAAC,aAAqB;IACzC,OAAO,UAAC,KAAa;QACnB,iCAAiC;QACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpC,mDAAmD;QACnD,wCAAwC;QACpC,IAAA,KAA2B,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAA7C,KAAK,QAAA,EAAE,UAAe,EAAf,UAAU,mBAAG,EAAE,KAAuB,CAAC;QACnD,oFAAoF;QACpF,UAAU,GAAG,UAAU;aACpB,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC;aAC1B,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QAC/B,+EAA+E;QAC/E,IAAM,cAAc,GAAG,KAAK,GAAG,UAAU,CAAC;QAC1C,mHAAmH;QACnH,2GAA2G;QAC3G,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,KAAK,SAiBhB;AAEK,IAAM,qBAAqB,GAAG,UACnC,YAAoB,EACpB,OAAwC;IAExC,IAAM,GAAG,GAAa;QACpB,4DAA4D;QAC5D,6DAA6D;QAC7D,qEAAqE;QACrE,2DAA2D;KAC5D,CAAC;IAEF,IAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAEjE,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAdW,QAAA,qBAAqB,yBAchC;AAEK,IAAM,gBAAgB,GAAG,UAAC,GAAW;IAC1C,OAAO,GAAG,CAAC,WAAW,EAAa,CAAC;AACtC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","sourcesContent":["import { ethers } from 'ethers';\nimport { Address } from '../../types';\n\nexport const descale = (tokenDecimals: number) => {\n const f = (value: bigint) => {\n return Number(ethers.formatUnits(value.toString(), tokenDecimals));\n };\n\n return f;\n};\n\nexport const scale = (tokenDecimals: number): ((value: number) => bigint) => {\n return (value: number): bigint => {\n // Convert the number to a string\n const valueStr = value.toString(10);\n // Split the string into whole and fractional parts\n // eslint-disable-next-line prefer-const\n let [whole, fractional = ''] = valueStr.split('.');\n // Ensure the fractional part is the correct length, padding with zeros if necessary\n fractional = fractional\n .padEnd(tokenDecimals, '0')\n .substring(0, tokenDecimals);\n // Concatenate the whole part with the correctly length-limited fractional part\n const scaledValueStr = whole + fractional;\n // Convert the concatenated string to a BigInt, assuming it represents a value in wei (or equivalent smallest unit)\n // This is safe as we're not losing precision - just scaling the number to its smallest unit representation\n return BigInt(scaledValueStr);\n };\n};\n\nexport const getERC20TokenContract = (\n tokenAddress: string,\n subject: ethers.Signer | ethers.Provider,\n): ethers.Contract => {\n const abi: string[] = [\n `function approve(address, uint256) external returns (bool)`,\n `function balanceOf(address) external view returns (uint256)`,\n `function allowance(address,address) external view returns (uint256)`,\n `function approve(address,uint256) external returns (bool)`,\n ];\n\n const contract = new ethers.Contract(tokenAddress, abi, subject);\n\n return contract;\n};\n\nexport const convertToAddress = (str: string): Address => {\n return str.toLowerCase() as Address;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.214.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
44
44
|
},
|
|
45
45
|
"packageManager": "pnpm@8.3.1",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "436c4f84f279b3fe6d465d9fd40c874c6847b04c"
|
|
47
47
|
}
|
|
@@ -786,6 +786,107 @@
|
|
|
786
786
|
"outputs": [],
|
|
787
787
|
"stateMutability": "nonpayable"
|
|
788
788
|
},
|
|
789
|
+
{
|
|
790
|
+
"type": "function",
|
|
791
|
+
"name": "executeViaPublisher",
|
|
792
|
+
"inputs": [
|
|
793
|
+
{
|
|
794
|
+
"name": "inputs",
|
|
795
|
+
"type": "tuple",
|
|
796
|
+
"internalType": "struct PeripheryExecutionViaPublisherInputs",
|
|
797
|
+
"components": [
|
|
798
|
+
{
|
|
799
|
+
"name": "accountId",
|
|
800
|
+
"type": "uint128",
|
|
801
|
+
"internalType": "uint128"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
"name": "commands",
|
|
805
|
+
"type": "tuple[]",
|
|
806
|
+
"internalType": "struct Command[]",
|
|
807
|
+
"components": [
|
|
808
|
+
{
|
|
809
|
+
"name": "commandType",
|
|
810
|
+
"type": "uint8",
|
|
811
|
+
"internalType": "enum CommandType"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
"name": "inputs",
|
|
815
|
+
"type": "bytes",
|
|
816
|
+
"internalType": "bytes"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"name": "marketId",
|
|
820
|
+
"type": "uint128",
|
|
821
|
+
"internalType": "uint128"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"name": "exchangeId",
|
|
825
|
+
"type": "uint128",
|
|
826
|
+
"internalType": "uint128"
|
|
827
|
+
}
|
|
828
|
+
]
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"name": "sig",
|
|
832
|
+
"type": "tuple",
|
|
833
|
+
"internalType": "struct EIP712Signature",
|
|
834
|
+
"components": [
|
|
835
|
+
{
|
|
836
|
+
"name": "v",
|
|
837
|
+
"type": "uint8",
|
|
838
|
+
"internalType": "uint8"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"name": "r",
|
|
842
|
+
"type": "bytes32",
|
|
843
|
+
"internalType": "bytes32"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
"name": "s",
|
|
847
|
+
"type": "bytes32",
|
|
848
|
+
"internalType": "bytes32"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"name": "deadline",
|
|
852
|
+
"type": "uint256",
|
|
853
|
+
"internalType": "uint256"
|
|
854
|
+
}
|
|
855
|
+
]
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"name": "publisherSig",
|
|
859
|
+
"type": "tuple",
|
|
860
|
+
"internalType": "struct EIP712Signature",
|
|
861
|
+
"components": [
|
|
862
|
+
{
|
|
863
|
+
"name": "v",
|
|
864
|
+
"type": "uint8",
|
|
865
|
+
"internalType": "uint8"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
"name": "r",
|
|
869
|
+
"type": "bytes32",
|
|
870
|
+
"internalType": "bytes32"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"name": "s",
|
|
874
|
+
"type": "bytes32",
|
|
875
|
+
"internalType": "bytes32"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"name": "deadline",
|
|
879
|
+
"type": "uint256",
|
|
880
|
+
"internalType": "uint256"
|
|
881
|
+
}
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
]
|
|
885
|
+
}
|
|
886
|
+
],
|
|
887
|
+
"outputs": [],
|
|
888
|
+
"stateMutability": "nonpayable"
|
|
889
|
+
},
|
|
789
890
|
{
|
|
790
891
|
"type": "function",
|
|
791
892
|
"name": "isCommandAllowed",
|
package/src/utils/token/utils.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const descale = (tokenDecimals: number) => {
|
|
|
12
12
|
export const scale = (tokenDecimals: number): ((value: number) => bigint) => {
|
|
13
13
|
return (value: number): bigint => {
|
|
14
14
|
// Convert the number to a string
|
|
15
|
-
const valueStr = value.toString();
|
|
15
|
+
const valueStr = value.toString(10);
|
|
16
16
|
// Split the string into whole and fractional parts
|
|
17
17
|
// eslint-disable-next-line prefer-const
|
|
18
18
|
let [whole, fractional = ''] = valueStr.split('.');
|