@mimicprotocol/lib-ts 0.0.1-rc.37 → 0.0.1-rc.39
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/CHANGELOG.md +12 -0
- package/constants.ts +1 -0
- package/package.json +6 -1
- package/src/environment.ts +17 -1
- package/src/helpers/constants.ts +1 -1
- package/src/types/ByteArray.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mimicprotocol/lib-ts
|
|
2
2
|
|
|
3
|
+
## 0.0.1-rc.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 48352fe: Add runner target on compilation
|
|
8
|
+
|
|
9
|
+
## 0.0.1-rc.38
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 73e9713: Add getCode function to get the code of an address (Only EVM)
|
|
14
|
+
|
|
3
15
|
## 0.0.1-rc.37
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const RUNNER_TARGET_VERSION = '0.0.1'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimicprotocol/lib-ts",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"version": "0.0.1-rc.39",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -12,8 +12,13 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"src",
|
|
14
14
|
"index.ts",
|
|
15
|
+
"constants.ts",
|
|
15
16
|
"asconfig.json"
|
|
16
17
|
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./index.ts",
|
|
20
|
+
"./constants": "./constants.ts"
|
|
21
|
+
},
|
|
17
22
|
"devDependencies": {
|
|
18
23
|
"@as-pect/cli": "8.1.0",
|
|
19
24
|
"assemblyscript": "0.27.36"
|
package/src/environment.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
TokenPriceQueryResponse,
|
|
21
21
|
} from './queries'
|
|
22
22
|
import { BlockchainToken, Token, TokenAmount, USD } from './tokens'
|
|
23
|
-
import { Address, BigInt, ChainId, EvmDecodeParam, EvmEncodeParam, Result } from './types'
|
|
23
|
+
import { Address, BigInt, Bytes, ChainId, EvmDecodeParam, EvmEncodeParam, Result } from './types'
|
|
24
24
|
|
|
25
25
|
export namespace environment {
|
|
26
26
|
@external('environment', '_evmCall')
|
|
@@ -219,4 +219,20 @@ export namespace environment {
|
|
|
219
219
|
const decoded = BigInt.fromString(decodedResponse)
|
|
220
220
|
return Result.ok<BigInt, string>(decoded)
|
|
221
221
|
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Returns the code of the target account.
|
|
225
|
+
* @param chainId - Chain id to check code
|
|
226
|
+
* @param target - Address to get code from
|
|
227
|
+
* @returns The code of the target account
|
|
228
|
+
*/
|
|
229
|
+
export function getCode(chainId: ChainId, target: Address): Result<Bytes, string> {
|
|
230
|
+
if (chainId === ChainId.SOLANA_MAINNET) return Result.err<Bytes, string>('Solana not supported')
|
|
231
|
+
const data = '0x7e105ce2' + evm.encode([EvmEncodeParam.fromValue('address', target)])
|
|
232
|
+
const response = evmCallQuery(Address.fromHexString(MIMIC_HELPER_ADDRESS), chainId, data)
|
|
233
|
+
if (response.isError) return Result.err<Bytes, string>(response.error)
|
|
234
|
+
const decodedResponse = evm.decode(new EvmDecodeParam('bytes', response.unwrap()))
|
|
235
|
+
const decoded = Bytes.fromHexString(decodedResponse)
|
|
236
|
+
return Result.ok<Bytes, string>(decoded)
|
|
237
|
+
}
|
|
222
238
|
}
|
package/src/helpers/constants.ts
CHANGED
package/src/types/ByteArray.ts
CHANGED