Skip to content

Commit

Permalink
update rates handler to support batching
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Dec 6, 2024
1 parent fd2cdc3 commit 7c96dda
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions SIPS/sip-29.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const onAssetLookup: OnAssetLookupHandler = async ({

The type for an `onAssetLookup` handler function’s arguments is:


```typescript
interface OnAssetLookupArgs {
assets: Caip19AssetType[];
Expand All @@ -96,19 +97,22 @@ type OnAssetLookupReturn = {
import { OnAssetConversionHandler } from "@metamask/snaps-sdk";

export const onAssetConversion: OnAssetConversionHandler = async ({
from,
to
conversions
}) => {
const conversionRate = /* Get conversion rate */;
return { conversionRate };
const conversionRates = /* Get conversion rate */;
return { conversionRates };
};
```
The type for an `onAssetConversion` handler function’s arguments is:

```typescript
interface OnAssetConversionArgs {
from: Caip19AssetType[];
type Conversion = {
from: Caip19AssetType;
to: Caip19AssetType;
};

type OnAssetConversionArgs = {
conversions: Conversion[];
}
```
The type for an `onAssetConversion` handler function’s return value is:
Expand All @@ -127,15 +131,12 @@ type AssetConversionRate = {
expirationTime: number;
};

type FromAsset = Conversion["from"];

// {
// rate: '3906.38',
// conversionTime: 1733389786,
// expirationTime: 1733389816,
// }
type ToAsset = Conversion["to"];

type OnAssetConversionReturn = {
conversionRate: Record<Caip19AssetType, AssetConversionRate>;
conversionRate: Record<From, Record<To, AssetConversionRate>>;
};
```

Expand Down

0 comments on commit 7c96dda

Please sign in to comment.