version: @optics-xyz/multi-provider@0.1.14 -- interface renaming and anna cleanup

buddies-main-deployment
James Prestwich 3 years ago
parent 259c89d33e
commit 5203f4c6ad
No known key found for this signature in database
GPG Key ID: 7CC174C250AD83AD
  1. 1
      .gitignore
  2. 4
      typescript/optics-provider/package-lock.json
  3. 2
      typescript/optics-provider/package.json
  4. 19
      typescript/optics-provider/src/optics/OpticsContext.ts
  5. 2
      typescript/optics-provider/src/optics/messages/BridgeMessage.ts
  6. 14
      typescript/optics-provider/src/tmp.ts
  7. 2
      typescript/optics-provider/tsconfig.json

1
.gitignore vendored

@ -4,6 +4,7 @@ test_deploy.env
typescript/optics-deploy/.env
**/.env
**/tsconfig.tsbuildinfo
**/tmp.*
rust/vendor/
rust/tmp_db

@ -1,12 +1,12 @@
{
"name": "@optics-xyz/multi-provider",
"version": "0.1.13",
"version": "0.1.14",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@optics-xyz/multi-provider",
"version": "0.1.13",
"version": "0.1.14",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@optics-xyz/ts-interface": "^1.1.0",

@ -1,6 +1,6 @@
{
"name": "@optics-xyz/multi-provider",
"version": "0.1.13",
"version": "0.1.14",
"description": "multi-provider for Optics",
"main": "dist/index.js",
"types": "dist/index.d.ts",

@ -121,6 +121,7 @@ export class OpticsContext extends MultiProvider {
?.contract;
}
// gets the replica of Home on Remote, or errors
mustGetReplicaFor(
home: string | number,
remote: string | number,
@ -133,7 +134,7 @@ export class OpticsContext extends MultiProvider {
}
// resolve the local repr of a token on its domain
async resolveTokenRepresentation(
async resolveRepresentation(
nameOrDomain: string | number,
token: TokenIdentifier,
): Promise<xapps.BridgeToken | undefined> {
@ -161,14 +162,14 @@ export class OpticsContext extends MultiProvider {
}
// resolve all token representations
async tokenRepresentations(
async resolveRepresentations(
token: TokenIdentifier,
): Promise<ResolvedTokenInfo> {
const tokens: Map<number, xapps.BridgeToken> = new Map();
await Promise.all(
this.domainNumbers.map(async (domain) => {
let tok = await this.resolveTokenRepresentation(domain, token);
let tok = await this.resolveRepresentation(domain, token);
if (tok) {
tokens.set(domain, tok);
}
@ -182,7 +183,8 @@ export class OpticsContext extends MultiProvider {
};
}
async resolveCanonicalTokenIdentifier(
// resolve the ID of the canonical token for a representation on some domain
async resolveCanonicalIdentifier(
nameOrDomain: string | number,
representation: Address,
): Promise<TokenIdentifier | undefined> {
@ -217,18 +219,20 @@ export class OpticsContext extends MultiProvider {
return;
}
// resolve an `ethers.Contract` for the canonical token for a representation
// on some domain
async resolveCanonicalToken(
nameOrDomain: string | number,
representation: Address,
): Promise<xapps.BridgeToken> {
const canonicalId = await this.resolveCanonicalTokenIdentifier(
const canonicalId = await this.resolveCanonicalIdentifier(
nameOrDomain,
representation,
);
if (!canonicalId) {
throw new Error('Token seems to not exist');
}
const token = await this.resolveTokenRepresentation(
const token = await this.resolveRepresentation(
canonicalId.domain,
canonicalId,
);
@ -252,7 +256,7 @@ export class OpticsContext extends MultiProvider {
const fromBridge = this.mustGetBridge(from);
const bridgeAddress = fromBridge.bridgeRouter.address;
const fromToken = await this.resolveTokenRepresentation(from, token);
const fromToken = await this.resolveRepresentation(from, token);
if (!fromToken) {
throw new Error(`Token not available on ${from}`);
}
@ -285,6 +289,7 @@ export class OpticsContext extends MultiProvider {
return message as TransferMessage;
}
// send the native asset from domain to domain (using EthHelper.sol)
async sendNative(
from: string | number,
to: string | number,

@ -225,7 +225,7 @@ class BridgeMessage extends OpticsMessage {
}
async asset(): Promise<ResolvedTokenInfo> {
return await this.context.tokenRepresentations(this.token);
return await this.context.resolveRepresentations(this.token);
}
// Get the asset at the orgin

@ -1,14 +0,0 @@
import { mainnet } from '.';
const celoRpc = 'https://forno.celo.org';
const polygonRpc =
'https://polygon-mainnet.infura.io/v3/58bafb6c28e6439c9e7d8bb8e83592e2';
const ethRpc = 'https://mainnet.infura.io/v3/58bafb6c28e6439c9e7d8bb8e83592e2';
mainnet.registerRpcProvider('celo', celoRpc);
mainnet.registerRpcProvider('ethereum', ethRpc);
mainnet.registerRpcProvider('polygon', polygonRpc);
export const mn = mainnet;

@ -4,7 +4,7 @@
"outDir": "./dist/",
"rootDir": "./src/"
},
"exclude": ["./node_modules/", "./dist/"],
"exclude": ["./node_modules/", "./dist/", "./src/tmp.ts"],
"include": [
"./src/*.ts",
"./src/optics/*.ts",

Loading…
Cancel
Save