@alephium/web3 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +114 -1
- package/dist/src/api/api-alephium.js +30 -1
- package/dist/src/api/api-explorer.d.ts +55 -0
- package/dist/src/api/api-explorer.js +28 -0
- package/dist/src/contract/contract.d.ts +3 -1
- package/dist/src/contract/contract.js +4 -2
- package/dist/src/utils/utils.d.ts +3 -0
- package/package.json +3 -3
- package/src/api/api-alephium.ts +144 -1
- package/src/api/api-explorer.ts +79 -0
- package/src/contract/contract.ts +5 -2
- package/src/utils/utils.ts +8 -0
package/src/contract/contract.ts
CHANGED
|
@@ -2046,12 +2046,14 @@ function toFieldsSig(contractName: string, functionSig: FunctionSig): FieldsSig
|
|
|
2046
2046
|
}
|
|
2047
2047
|
}
|
|
2048
2048
|
|
|
2049
|
+
type Calls = Record<string, Optional<CallContractParams<any>, 'args'>>
|
|
2049
2050
|
export async function multicallMethods<I extends ContractInstance, F extends Fields>(
|
|
2050
2051
|
contract: ContractFactory<I, F>,
|
|
2051
2052
|
instance: ContractInstance,
|
|
2052
|
-
|
|
2053
|
+
_callss: Calls | Calls[],
|
|
2053
2054
|
getContractByCodeHash: (codeHash: string) => Contract
|
|
2054
2055
|
): Promise<Record<string, CallContractResult<any>>[] | Record<string, CallContractResult<any>>> {
|
|
2056
|
+
const callss = Array.isArray(_callss) ? _callss : [_callss]
|
|
2055
2057
|
const callEntries = callss.map((calls) => Object.entries(calls))
|
|
2056
2058
|
const callsParams = callEntries.map((entries) => {
|
|
2057
2059
|
return entries.map((entry) => {
|
|
@@ -2068,7 +2070,7 @@ export async function multicallMethods<I extends ContractInstance, F extends Fie
|
|
|
2068
2070
|
})
|
|
2069
2071
|
const result = await getCurrentNodeProvider().contracts.postContractsMulticallContract({ calls: callsParams.flat() })
|
|
2070
2072
|
let callResultIndex = 0
|
|
2071
|
-
|
|
2073
|
+
const results = callsParams.map((calls, index0) => {
|
|
2072
2074
|
const callsResult: Record<string, CallContractResult<any>> = {}
|
|
2073
2075
|
const entries = callEntries[`${index0}`]
|
|
2074
2076
|
calls.forEach((call, index1) => {
|
|
@@ -2085,6 +2087,7 @@ export async function multicallMethods<I extends ContractInstance, F extends Fie
|
|
|
2085
2087
|
})
|
|
2086
2088
|
return callsResult
|
|
2087
2089
|
})
|
|
2090
|
+
return Array.isArray(_callss) ? results : results[0]
|
|
2088
2091
|
}
|
|
2089
2092
|
|
|
2090
2093
|
export async function getContractEventsCurrentCount(contractAddress: Address): Promise<number> {
|
package/src/utils/utils.ts
CHANGED
|
@@ -169,3 +169,11 @@ export type Eq<X, Y> = _Eq<{ [P in keyof X]: X[P] }, { [P in keyof Y]: Y[P] }>
|
|
|
169
169
|
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
|
|
170
170
|
export function assertType<T extends true>(): void {}
|
|
171
171
|
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
172
|
+
|
|
173
|
+
export type Narrow<type> =
|
|
174
|
+
| (unknown extends type ? unknown : never)
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
176
|
+
| (type extends Function ? type : never)
|
|
177
|
+
| (type extends bigint | boolean | number | string ? type : never)
|
|
178
|
+
| (type extends [] ? [] : never)
|
|
179
|
+
| { [K in keyof type]: Narrow<type[K]> }
|