@mimicprotocol/lib-ts 0.0.1-rc.35 → 0.0.1-rc.36

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @mimicprotocol/lib-ts
2
2
 
3
+ ## 0.0.1-rc.36
4
+
5
+ ### Patch Changes
6
+
7
+ - 6a4fb70: rename to use functions
8
+
3
9
  ## 0.0.1-rc.35
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -25,11 +25,11 @@
25
25
 
26
26
  ## Content
27
27
 
28
- This package provides a lightweight standard library for writing Mimic Protocol tasks in AssemblyScript. It includes:
28
+ This package provides a lightweight standard library for writing Mimic Protocol functions in AssemblyScript. It includes:
29
29
 
30
30
  - Typed primitives to interact with oracles and contracts
31
31
  - Safe and minimal bindings for blockchain-specific operations
32
- - Utility helpers for developing deterministic, deployable task logic
32
+ - Utility helpers for developing deterministic, deployable function logic
33
33
 
34
34
  ## Setup
35
35
 
@@ -50,7 +50,7 @@ $ yarn
50
50
 
51
51
  ## Usage
52
52
 
53
- Here’s an example of how to use the library in a Mimic task:
53
+ Here’s an example of how to use the library in a Mimic function:
54
54
 
55
55
  ```ts
56
56
  import { environment, ERC20Token } from '@mimicprotocol/lib-ts'
@@ -60,7 +60,7 @@ const USDC = ERC20Token.fromString('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
60
60
  environment.tokenPriceQuery(USDC, new Date(1744818017000))
61
61
  ```
62
62
 
63
- For full task development guide and examples please visit [docs.mimic.fi](https://docs.mimic.fi/)
63
+ For full function development guide and examples please visit [docs.mimic.fi](https://docs.mimic.fi/)
64
64
 
65
65
  ## Security
66
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimicprotocol/lib-ts",
3
- "version": "0.0.1-rc.35",
3
+ "version": "0.0.1-rc.36",
4
4
  "license": "GPL-3.0",
5
5
  "private": false,
6
6
  "type": "module",
@@ -22,14 +22,14 @@ export class Settler {
22
22
  }
23
23
 
24
24
  @json
25
- export class SerializableTrigger {
25
+ export class SerializableTriggerPayload {
26
26
  constructor(
27
27
  public type: u8,
28
28
  public data: string
29
29
  ) {}
30
30
  }
31
31
 
32
- export class EventTriggerData {
32
+ export class EventTriggerPayloadData {
33
33
  constructor(
34
34
  public chainId: BigInt,
35
35
  public blockHash: string,
@@ -41,35 +41,35 @@ export class EventTriggerData {
41
41
  }
42
42
 
43
43
  @json
44
- export class Trigger {
44
+ export class TriggerPayload {
45
45
  constructor(
46
46
  public type: TriggerType,
47
47
  public data: string
48
48
  ) {}
49
49
 
50
- static fromSerializable(serializable: SerializableTrigger): Trigger {
51
- return new Trigger(serializable.type, serializable.data)
50
+ static fromSerializable(serializable: SerializableTriggerPayload): TriggerPayload {
51
+ return new TriggerPayload(serializable.type, serializable.data)
52
52
  }
53
53
 
54
54
  getCronData(): BigInt {
55
- if (this.type !== TriggerType.CRON) throw new Error("Can't get cron data, trigger type is not cron")
56
- return Trigger.deserializeCronTriggerData(this.data)
55
+ if (this.type !== TriggerType.CRON) throw new Error("Can't get cron data, config type is not cron")
56
+ return TriggerPayload.deserializeCronTriggerPayloadData(this.data)
57
57
  }
58
58
 
59
- getEventData(): EventTriggerData {
60
- if (this.type !== TriggerType.EVENT) throw new Error("Can't get event data, trigger type is not event")
61
- return Trigger.deserializeEventTriggerData(this.data)
59
+ getEventData(): EventTriggerPayloadData {
60
+ if (this.type !== TriggerType.EVENT) throw new Error("Can't get event data, config type is not event")
61
+ return TriggerPayload.deserializeEventTriggerPayloadData(this.data)
62
62
  }
63
63
 
64
- static deserializeCronTriggerData(data: string): BigInt {
64
+ static deserializeCronTriggerPayloadData(data: string): BigInt {
65
65
  return BigInt.fromString(evm.decode(new EvmDecodeParam('uint256', data)))
66
66
  }
67
67
 
68
- static deserializeEventTriggerData(data: string): EventTriggerData {
68
+ static deserializeEventTriggerPayloadData(data: string): EventTriggerPayloadData {
69
69
  const fields = JSON.parse<string[]>(
70
70
  evm.decode(new EvmDecodeParam('(uint256,bytes32,uint256,address,bytes32[],bytes)', data))
71
71
  )
72
- return new EventTriggerData(
72
+ return new EventTriggerPayloadData(
73
73
  BigInt.fromString(fields[0]),
74
74
  fields[1],
75
75
  BigInt.fromString(fields[2]),
@@ -87,8 +87,8 @@ export class SerializableContext {
87
87
  public readonly consensusThreshold: u8,
88
88
  public user: string,
89
89
  public settlers: SerializableSettler[],
90
- public configSig: string,
91
- public trigger: SerializableTrigger
90
+ public triggerSig: string,
91
+ public triggerPayload: SerializableTriggerPayload
92
92
  ) {}
93
93
  }
94
94
 
@@ -98,8 +98,8 @@ export class Context {
98
98
  public readonly consensusThreshold: u8,
99
99
  public user: Address,
100
100
  public settlers: Settler[],
101
- public configSig: string,
102
- public trigger: Trigger
101
+ public triggerSig: string,
102
+ public triggerPayload: TriggerPayload
103
103
  ) {}
104
104
 
105
105
  static fromSerializable(serializable: SerializableContext): Context {
@@ -108,8 +108,8 @@ export class Context {
108
108
  serializable.consensusThreshold,
109
109
  Address.fromString(serializable.user),
110
110
  serializable.settlers.map<Settler>((s) => Settler.fromSerializable(s)),
111
- serializable.configSig,
112
- Trigger.fromSerializable(serializable.trigger)
111
+ serializable.triggerSig,
112
+ TriggerPayload.fromSerializable(serializable.triggerPayload)
113
113
  )
114
114
  }
115
115
 
@@ -197,7 +197,7 @@ export namespace environment {
197
197
 
198
198
  /**
199
199
  * Returns the current execution context containing environment information.
200
- * @returns The Context object containing: user, settler, timestamp, and config ID
200
+ * @returns The Context object containing: user, settler, timestamp, consensusThreshold and triggerPayload
201
201
  */
202
202
  export function getContext(): Context {
203
203
  const context = JSON.parse<SerializableContext>(_getContext())
@@ -239,7 +239,7 @@ export abstract class Intent {
239
239
  this.events = events || []
240
240
  this.nonce = nonce
241
241
  ? nonce
242
- : evm.keccak(`${context.configSig}${context.timestamp}${context.trigger.data}${++INTENT_INDEX}`)
242
+ : evm.keccak(`${context.triggerSig}${context.timestamp}${context.triggerPayload.data}${++INTENT_INDEX}`)
243
243
 
244
244
  if (!this.user || this.user == NULL_ADDRESS) throw new Error('A user must be specified')
245
245
  if (!this.settler || this.settler == NULL_ADDRESS) throw new Error('A settler contract must be specified')