Rename abacus-sdk (#127)

* Rename abacus-sdk

* Github workflow changes

* Update README.md
pull/129/head
Nam Chu Hoai 3 years ago committed by GitHub
parent 79f1f200e8
commit 0f6c1bf635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      .github/workflows/npm/action.yml
  2. 4
      .github/workflows/typescript.yml
  3. 0
      typescript/abacus-sdk/.eslintignore
  4. 0
      typescript/abacus-sdk/.eslintrc.json
  5. 0
      typescript/abacus-sdk/.gitignore
  6. 0
      typescript/abacus-sdk/.npmignore
  7. 0
      typescript/abacus-sdk/.prettierrc
  8. 14
      typescript/abacus-sdk/README.md
  9. 5893
      typescript/abacus-sdk/package-lock.json
  10. 2
      typescript/abacus-sdk/package.json
  11. 30
      typescript/abacus-sdk/src/abacus/AbacusContext.ts
  12. 2
      typescript/abacus-sdk/src/abacus/contracts/BridgeContracts.ts
  13. 2
      typescript/abacus-sdk/src/abacus/contracts/CoreContracts.ts
  14. 0
      typescript/abacus-sdk/src/abacus/contracts/index.ts
  15. 12
      typescript/abacus-sdk/src/abacus/domains/dev.ts
  16. 2
      typescript/abacus-sdk/src/abacus/domains/domain.ts
  17. 2
      typescript/abacus-sdk/src/abacus/domains/index.ts
  18. 10
      typescript/abacus-sdk/src/abacus/domains/mainnet.ts
  19. 8
      typescript/abacus-sdk/src/abacus/domains/mainnetLegacy.ts
  20. 10
      typescript/abacus-sdk/src/abacus/domains/testnet.ts
  21. 8
      typescript/abacus-sdk/src/abacus/domains/testnetLegacy.ts
  22. 4
      typescript/abacus-sdk/src/abacus/events/abacusEvents.ts
  23. 2
      typescript/abacus-sdk/src/abacus/events/bridgeEvents.ts
  24. 16
      typescript/abacus-sdk/src/abacus/events/fetch.ts
  25. 6
      typescript/abacus-sdk/src/abacus/events/index.ts
  26. 0
      typescript/abacus-sdk/src/abacus/examples/sendCoins.ts
  27. 0
      typescript/abacus-sdk/src/abacus/govern/index.ts
  28. 2
      typescript/abacus-sdk/src/abacus/govern/utils.ts
  29. 14
      typescript/abacus-sdk/src/abacus/index.ts
  30. 60
      typescript/abacus-sdk/src/abacus/messages/AbacusMessage.ts
  31. 66
      typescript/abacus-sdk/src/abacus/messages/BridgeMessage.ts
  32. 2
      typescript/abacus-sdk/src/abacus/messages/index.ts
  33. 2
      typescript/abacus-sdk/src/abacus/tokens/index.ts
  34. 0
      typescript/abacus-sdk/src/abacus/tokens/testnetWellKnown.ts
  35. 0
      typescript/abacus-sdk/src/abacus/tokens/wellKnown.ts
  36. 0
      typescript/abacus-sdk/src/contracts.ts
  37. 0
      typescript/abacus-sdk/src/domains.ts
  38. 10
      typescript/abacus-sdk/src/index.ts
  39. 0
      typescript/abacus-sdk/src/metamask.ts
  40. 2
      typescript/abacus-sdk/src/provider.ts
  41. 2
      typescript/abacus-sdk/src/utils.ts
  42. 18
      typescript/abacus-sdk/tsconfig.json
  43. 2674
      typescript/optics-provider/package-lock.json
  44. 18
      typescript/optics-provider/tsconfig.json

@ -50,12 +50,12 @@ runs:
path: ./typescript/typechain/node_modules
key: ${{ inputs.runneros }}-typechain-cache-${{ hashFiles('typescript/typechain/package-lock.json') }}
- name: Multi-Provider Cache
id: provider-cache
- name: Abacus SDK Cache
id: sdk-cache
uses: actions/cache@v2
with:
path: ./typescript/optics-provider/node_modules
key: ${{ inputs.runneros }}-provider-cache-${{ hashFiles('typescript/optics-provider/package-lock.json') }}
path: ./typescript/abacus-sdk/node_modules
key: ${{ inputs.runneros }}-sdk-cache-${{ hashFiles('typescript/abacus-sdk/package-lock.json') }}
- name: Metrics Cache
id: metrics-cache
@ -93,7 +93,7 @@ runs:
- name: Install Multi-Provider
shell: bash
if: steps.provider-cache.outputs.cache-hit != 'true'
run: cd ./typescript/optics-provider && npm i
run: cd ./typescript/abacus-sdk && npm i
- name: Install Metrics
shell: bash

@ -36,7 +36,7 @@ jobs:
npm run build
cd ../optics-deploy
npm run build
cd ../optics-provider
cd ../abacus-sdk
npm run build
cd ../typechain
npm run build
@ -54,7 +54,7 @@ jobs:
run: |
cd ./typescript/optics-deploy
npm run prettier
cd ../optics-provider
cd ../abacus-sdk
npm run prettier
cd ../abacus-tests
npm run prettier-ci

@ -1,13 +1,13 @@
## Optics Provider
## Abacus SDK
Optics Provider is a management system for
Abacus SDK is a management system for
[ethers.js](https://docs.ethers.io/v5/) providers and signers that helps
developers connect to multiple networks simultaneously. It is part
of the [Optics](https://github.com/celo-org/optics-monorepo) project, but may
of the [Abacus](https://github.com/celo-org/optics-monorepo) project, but may
be useful to other multi-chain systems.
This package includes the `MultiProvider`, as well as an `OpticsContext` for
interacting with deployed Optics systems. The dev, staging, and mainnet Optics
This package includes the `MultiProvider`, as well as an `AbacusContext` for
interacting with deployed Abacus systems. The dev, staging, and mainnet Abacus
systems have pre-built objects for quick development.
### Intended Usage
@ -15,7 +15,7 @@ systems have pre-built objects for quick development.
```ts
import * as ethers from 'ethers';
import { mainnet } from 'optics-provider';
import { mainnet } from '@abacus-network/sdk';
// Set up providers and signers
const someEthersProvider = ethers.providers.WsProvider('...');
@ -27,7 +27,7 @@ mainnet.registerSigner('ethereum', someEthersSigner);
mainnet.registerRpcProvider('celo', 'https://forno.celo.org');
mainnet.registerWalletSigner('celo', '0xabcd...');
// Interact with the Optics Bridge
// Interact with the Abacus Bridge
// Send ETH from ethereum to celo
await mainnet.sendNative(
'ethereum', // source

File diff suppressed because it is too large Load Diff

@ -30,6 +30,6 @@
"@ethersproject/bytes": "^5.5.0",
"celo-ethers-provider": "0.0.0",
"ethers": "^5.4.7",
"optics-ts-interface": "^1.1.2"
"@abacus-network/ts-interface": "^1.1.2"
}
}

@ -1,6 +1,6 @@
import { BigNumberish, ethers } from 'ethers';
import { MultiProvider } from '..';
import { xapps, core } from 'optics-ts-interface';
import { xapps, core } from '@abacus-network/ts-interface';
import { BridgeContracts } from './contracts/BridgeContracts';
import { CoreContracts } from './contracts/CoreContracts';
import { ResolvedTokenInfo, TokenIdentifier } from './tokens';
@ -9,7 +9,7 @@ import {
devDomains,
mainnetDomains,
mainnetLegacyDomains,
OpticsDomain,
AbacusDomain,
testnetDomains,
testnetLegacyDomains,
} from './domains';
@ -19,7 +19,7 @@ import { hexlify } from '@ethersproject/bytes';
type Address = string;
/**
* The OpticsContext managers connections to Optics core and Bridge contracts.
* The AbacusContext managers connections to Abacus core and Bridge contracts.
* It inherits from the {@link MultiProvider}, and ensures that its contracts
* always use the latest registered providers and signers.
*
@ -30,13 +30,13 @@ type Address = string;
* // Set up mainnet and then access contracts as below:
* let router = mainnet.mustGetBridge('celo').bridgeRouter;
*/
export class OpticsContext extends MultiProvider {
export class AbacusContext extends MultiProvider {
private cores: Map<number, CoreContracts>;
private bridges: Map<number, BridgeContracts>;
private _governorDomain?: number;
constructor(
domains: OpticsDomain[],
domains: AbacusDomain[],
cores: CoreContracts[],
bridges: BridgeContracts[],
) {
@ -54,15 +54,15 @@ export class OpticsContext extends MultiProvider {
}
/**
* Instantiate an OpticsContext from contract info.
* Instantiate an AbacusContext from contract info.
*
* @param domains An array of Domains with attached contract info
* @returns A context object
*/
static fromDomains(domains: OpticsDomain[]): OpticsContext {
static fromDomains(domains: AbacusDomain[]): AbacusContext {
const cores = domains.map((domain) => CoreContracts.fromObject(domain));
const bridges = domains.map((domain) => BridgeContracts.fromObject(domain));
return new OpticsContext(domains, cores, bridges);
return new AbacusContext(domains, cores, bridges);
}
/**
@ -226,7 +226,7 @@ export class OpticsContext extends MultiProvider {
}
/**
* Discovers the governor domain of this optics deployment and caches it.
* Discovers the governor domain of this abacus deployment and caches it.
*
* @returns The identifier of the governing domain
*/
@ -244,7 +244,7 @@ export class OpticsContext extends MultiProvider {
}
/**
* Discovers the governor domain of this optics deployment and returns the
* Discovers the governor domain of this abacus deployment and returns the
* associated Core.
*
* @returns The identifier of the governing domain
@ -499,8 +499,8 @@ export class OpticsContext extends MultiProvider {
}
}
export const testnetLegacy = OpticsContext.fromDomains(testnetLegacyDomains);
export const mainnetLegacy = OpticsContext.fromDomains(mainnetLegacyDomains);
export const dev = OpticsContext.fromDomains(devDomains);
export const testnet = OpticsContext.fromDomains(testnetDomains);
export const mainnet = OpticsContext.fromDomains(mainnetDomains);
export const testnetLegacy = AbacusContext.fromDomains(testnetLegacyDomains);
export const mainnetLegacy = AbacusContext.fromDomains(mainnetLegacyDomains);
export const dev = AbacusContext.fromDomains(devDomains);
export const testnet = AbacusContext.fromDomains(testnetDomains);
export const mainnet = AbacusContext.fromDomains(mainnetDomains);

@ -1,5 +1,5 @@
import { ethers } from 'ethers';
import { xapps } from 'optics-ts-interface';
import { xapps } from '@abacus-network/ts-interface';
import { Contracts } from '../../contracts';
type Address = string;

@ -1,5 +1,5 @@
import { ethers } from 'ethers';
import { core } from 'optics-ts-interface';
import { core } from '@abacus-network/ts-interface';
import { Contracts } from '../../contracts';
import { ReplicaInfo } from '../domains/domain';
import { CallBatch } from '../govern';

@ -1,6 +1,6 @@
import { OpticsDomain } from './domain';
import { AbacusDomain } from './domain';
export const alfajores: OpticsDomain = {
export const alfajores: AbacusDomain = {
name: 'alfajores',
id: 1000,
bridgeRouter: '0x684C74fBA4dF7F7A542709C5f9688AB806C7B828',
@ -15,7 +15,7 @@ export const alfajores: OpticsDomain = {
xAppConnectionManager: '0x2d230eB17F3AFe032809EC13A0E516E297b17AA3',
};
export const kovan: OpticsDomain = {
export const kovan: AbacusDomain = {
name: 'kovan',
id: 3000,
bridgeRouter: '0x53d09A4B49443F7f7C66321C306601dC9d483D4F',
@ -31,7 +31,7 @@ export const kovan: OpticsDomain = {
xAppConnectionManager: '0xf9db87020527A5A5aeFd95099051Fb14058916C9',
};
export const gorli: OpticsDomain = {
export const gorli: AbacusDomain = {
name: 'gorli',
id: 5,
bridgeRouter: '0x53d09A4B49443F7f7C66321C306601dC9d483D4F',
@ -47,7 +47,7 @@ export const gorli: OpticsDomain = {
xAppConnectionManager: '0xf9db87020527A5A5aeFd95099051Fb14058916C9',
};
export const fuji: OpticsDomain = {
export const fuji: AbacusDomain = {
name: 'fuji',
id: 43113,
bridgeRouter: '0xFE7c9Cc7116429Ae50823a218315C7E01EC7A761',
@ -63,7 +63,7 @@ export const fuji: OpticsDomain = {
xAppConnectionManager: '0xf9db87020527A5A5aeFd95099051Fb14058916C9',
};
export const mumbai: OpticsDomain = {
export const mumbai: AbacusDomain = {
name: 'mumbai',
id: 80001,
bridgeRouter: '0xFE7c9Cc7116429Ae50823a218315C7E01EC7A761',

@ -1,7 +1,7 @@
import { Domain } from '../../domains';
import { Address } from '../../utils';
export interface OpticsDomain extends Domain {
export interface AbacusDomain extends Domain {
bridgeRouter: Address;
ethHelper?: Address;
home: Address;

@ -1,4 +1,4 @@
export type { OpticsDomain, ReplicaInfo } from './domain';
export type { AbacusDomain, ReplicaInfo } from './domain';
export { mainnetDomains } from './mainnet';
export { mainnetLegacyDomains } from './mainnetLegacy';
export { devDomains } from './dev';

@ -1,6 +1,6 @@
import { OpticsDomain } from './domain';
import { AbacusDomain } from './domain';
export const celo: OpticsDomain = {
export const celo: AbacusDomain = {
name: 'celo',
id: 1667591279,
bridgeRouter: '0x1548cf5cf7dBd93f4dA11f45fCce315573d21B60',
@ -20,7 +20,7 @@ export const celo: OpticsDomain = {
],
};
export const ethereum: OpticsDomain = {
export const ethereum: AbacusDomain = {
name: 'ethereum',
id: 6648936,
bridgeRouter: '0x4fc16De11deAc71E8b2Db539d82d93BE4b486892',
@ -44,7 +44,7 @@ export const ethereum: OpticsDomain = {
],
};
export const avalanche: OpticsDomain = {
export const avalanche: AbacusDomain = {
name: 'avalanche',
id: 1635148152,
paginate: {
@ -69,7 +69,7 @@ export const avalanche: OpticsDomain = {
],
};
export const polygon: OpticsDomain = {
export const polygon: AbacusDomain = {
name: 'polygon',
id: 1886350457,
paginate: {

@ -1,6 +1,6 @@
import { OpticsDomain } from './domain';
import { AbacusDomain } from './domain';
export const ethereum: OpticsDomain = {
export const ethereum: AbacusDomain = {
name: 'ethereum',
id: 6648936,
bridgeRouter: '0x6a39909e805A3eaDd2b61fFf61147796ca6aBB47',
@ -20,7 +20,7 @@ export const ethereum: OpticsDomain = {
],
};
export const polygon: OpticsDomain = {
export const polygon: AbacusDomain = {
name: 'polygon',
id: 1886350457,
paginate: {
@ -42,7 +42,7 @@ export const polygon: OpticsDomain = {
],
};
export const celo: OpticsDomain = {
export const celo: AbacusDomain = {
name: 'celo',
id: 1667591279,
bridgeRouter: '0xf244eA81F715F343040569398A4E7978De656bf6',

@ -1,6 +1,6 @@
import { OpticsDomain } from './domain';
import { AbacusDomain } from './domain';
export const alfajores: OpticsDomain = {
export const alfajores: AbacusDomain = {
name: 'alfajores',
id: 1000,
bridgeRouter: '0xe29Abbc3669064d8aF9F6BE378179a133664a92C',
@ -14,7 +14,7 @@ export const alfajores: OpticsDomain = {
],
};
export const ropsten: OpticsDomain = {
export const ropsten: AbacusDomain = {
name: 'ropsten',
id: 3,
bridgeRouter: '0xe29Abbc3669064d8aF9F6BE378179a133664a92C',
@ -29,7 +29,7 @@ export const ropsten: OpticsDomain = {
],
};
export const kovan: OpticsDomain = {
export const kovan: AbacusDomain = {
name: 'kovan',
id: 3000,
bridgeRouter: '0x9A0e88a3D8CF09F3dc5Ba65640299DE3D87f926C',
@ -44,7 +44,7 @@ export const kovan: OpticsDomain = {
],
};
export const gorli: OpticsDomain = {
export const gorli: AbacusDomain = {
name: 'gorli',
id: 5,
bridgeRouter: '0xe29Abbc3669064d8aF9F6BE378179a133664a92C',

@ -1,6 +1,6 @@
import { OpticsDomain } from './domain';
import { AbacusDomain } from './domain';
export const alfajores: OpticsDomain = {
export const alfajores: AbacusDomain = {
name: 'alfajores',
id: 1000,
bridgeRouter: '0xd6930Ee55C141E5Bb4079d5963cF64320956bb3E',
@ -13,7 +13,7 @@ export const alfajores: OpticsDomain = {
],
};
export const kovan: OpticsDomain = {
export const kovan: AbacusDomain = {
name: 'kovan',
id: 3000,
bridgeRouter: '0x359089D34687bDbFD019fCC5093fFC21bE9905f5',
@ -27,7 +27,7 @@ export const kovan: OpticsDomain = {
],
};
export const rinkeby: OpticsDomain = {
export const rinkeby: AbacusDomain = {
name: 'rinkeby',
id: 2000,
bridgeRouter: '0x8FbEA25D0bFDbff68F2B920df180e9498E9c856A',

@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber';
import { Result } from '@ethersproject/abi';
import { TransactionReceipt } from '@ethersproject/abstract-provider';
import { TypedEvent } from 'optics-ts-interface/dist/optics-core/commons';
import { TypedEvent } from '@abacus-network/ts-interface/dist/abacus-core/commons';
// copied from the Home.d.ts
export type DispatchTypes = [string, BigNumber, BigNumber, string, string];
@ -34,7 +34,7 @@ export type ProcessArgs = {
};
export type ProcessEvent = TypedEvent<ProcessTypes & ProcessArgs>;
export type OpticsLifecyleEvent = ProcessEvent | UpdateEvent | DispatchEvent;
export type AbacusLifecyleEvent = ProcessEvent | UpdateEvent | DispatchEvent;
export class Annotated<U extends Result, T extends TypedEvent<U>> {
readonly domain: number;

@ -1,4 +1,4 @@
import { TypedEvent } from 'optics-ts-interface/dist/optics-core/commons';
import { TypedEvent } from '@abacus-network/ts-interface/dist/abacus-core/commons';
import { BigNumber } from 'ethers';
import { Annotated } from '.';

@ -1,11 +1,11 @@
import { Annotated } from '.';
import { OpticsContext } from '..';
import { AbacusContext } from '..';
import { Domain } from '../../domains';
import { Result } from '@ethersproject/abi';
import {
TypedEvent,
TypedEventFilter,
} from 'optics-ts-interface/dist/optics-core/commons';
} from '@abacus-network/ts-interface/dist/abacus-core/commons';
// specifies an interface shared by the TS generated contracts
export interface TSContract<T extends Result, U> {
@ -17,7 +17,7 @@ export interface TSContract<T extends Result, U> {
}
export async function queryAnnotatedEvents<T extends Result, U>(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
contract: TSContract<T, U>,
filter: TypedEventFilter<T, U>,
@ -36,7 +36,7 @@ export async function queryAnnotatedEvents<T extends Result, U>(
}
export async function findAnnotatedSingleEvent<T extends Result, U>(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
contract: TSContract<T, U>,
filter: TypedEventFilter<T, U>,
@ -53,7 +53,7 @@ export async function findAnnotatedSingleEvent<T extends Result, U>(
}
export async function getEvents<T extends Result, U>(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
contract: TSContract<T, U>,
filter: TypedEventFilter<T, U>,
@ -75,7 +75,7 @@ export async function getEvents<T extends Result, U>(
}
export async function findEvent<T extends Result, U>(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
contract: TSContract<T, U>,
filter: TypedEventFilter<T, U>,
@ -95,7 +95,7 @@ export async function findEvent<T extends Result, U>(
}
async function getPaginatedEvents<T extends Result, U>(
context: OpticsContext,
context: AbacusContext,
domain: Domain,
contract: TSContract<T, U>,
filter: TypedEventFilter<T, U>,
@ -141,7 +141,7 @@ async function getPaginatedEvents<T extends Result, U>(
}
async function findFromPaginatedEvents<T extends Result, U>(
context: OpticsContext,
context: AbacusContext,
domain: Domain,
contract: TSContract<T, U>,
filter: TypedEventFilter<T, U>,

@ -3,7 +3,7 @@ export type {
AnnotatedUpdate,
AnnotatedProcess,
AnnotatedLifecycleEvent,
OpticsLifecyleEvent,
AbacusLifecyleEvent,
DispatchEvent,
ProcessEvent,
UpdateEvent,
@ -13,9 +13,9 @@ export type {
ProcessTypes,
DispatchArgs,
DispatchTypes,
} from './opticsEvents';
} from './abacusEvents';
export { Annotated } from './opticsEvents';
export { Annotated } from './abacusEvents';
export type {
SendTypes,

@ -8,7 +8,7 @@ export function byteLength(bytesLike: ethers.utils.BytesLike): number {
}
/**
* Serialize a call to its packed Optics governance representation
* Serialize a call to its packed Abacus governance representation
* @param call The function call to serialize
* @returns The serialized function call, as a '0x'-prepended hex string
*/

@ -8,15 +8,15 @@ export {
} from './messages/BridgeMessage';
export {
OpticsMessage,
OpticsStatus,
AbacusMessage,
AbacusStatus,
MessageStatus,
} from './messages/OpticsMessage';
} from './messages/AbacusMessage';
export type { ResolvedTokenInfo, TokenIdentifier } from './tokens';
export { tokens, testnetTokens } from './tokens';
export type { OpticsDomain } from './domains';
export type { AbacusDomain } from './domains';
export {
testnetLegacyDomains,
mainnetLegacyDomains,
@ -25,7 +25,7 @@ export {
mainnetDomains,
} from './domains';
export type { AnnotatedLifecycleEvent, OpticsLifecyleEvent } from './events';
export type { AnnotatedLifecycleEvent, AbacusLifecyleEvent } from './events';
export {
queryAnnotatedEvents,
findAnnotatedSingleEvent,
@ -33,10 +33,10 @@ export {
} from './events';
export {
OpticsContext,
AbacusContext,
testnetLegacy,
mainnetLegacy,
dev,
testnet,
mainnet,
} from './OpticsContext';
} from './AbacusContext';

@ -1,8 +1,8 @@
import { BigNumber } from '@ethersproject/bignumber';
import { arrayify, hexlify } from '@ethersproject/bytes';
import { TransactionReceipt } from '@ethersproject/abstract-provider';
import { core } from 'optics-ts-interface';
import { OpticsContext } from '..';
import { core } from '@abacus-network/ts-interface';
import { AbacusContext } from '..';
import { delay } from '../../utils';
import {
DispatchEvent,
@ -30,7 +30,7 @@ export type ParsedMessage = {
body: string;
};
export type OpticsStatus = {
export type AbacusStatus = {
status: MessageStatus;
events: AnnotatedLifecycleEvent[];
};
@ -55,7 +55,7 @@ export type EventCache = {
};
/**
* Parse a serialized Optics message from raw bytes.
* Parse a serialized Abacus message from raw bytes.
*
* @param message
* @returns
@ -72,18 +72,18 @@ export function parseMessage(message: string): ParsedMessage {
}
/**
* A deserialized Optics message.
* A deserialized Abacus message.
*/
export class OpticsMessage {
export class AbacusMessage {
readonly dispatch: AnnotatedDispatch;
readonly message: ParsedMessage;
readonly home: core.Home;
readonly replica: core.Replica;
readonly context: OpticsContext;
readonly context: AbacusContext;
protected cache: EventCache;
constructor(context: OpticsContext, dispatch: AnnotatedDispatch) {
constructor(context: AbacusContext, dispatch: AnnotatedDispatch) {
this.context = context;
this.message = parseMessage(dispatch.event.args.message);
this.dispatch = dispatch;
@ -105,17 +105,17 @@ export class OpticsMessage {
/**
* Instantiate one or more messages from a receipt.
*
* @param context the {@link OpticsContext} object to use
* @param context the {@link AbacusContext} object to use
* @param nameOrDomain the domain on which the receipt was logged
* @param receipt the receipt
* @returns an array of {@link OpticsMessage} objects
* @returns an array of {@link AbacusMessage} objects
*/
static fromReceipt(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
receipt: TransactionReceipt,
): OpticsMessage[] {
const messages: OpticsMessage[] = [];
): AbacusMessage[] {
const messages: AbacusMessage[] = [];
const home = new core.Home__factory().interface;
for (const log of receipt.logs) {
@ -146,7 +146,7 @@ export class OpticsMessage {
true,
);
annotated.event.blockNumber = annotated.receipt.blockNumber;
const message = new OpticsMessage(context, annotated);
const message = new AbacusMessage(context, annotated);
messages.push(message);
}
} catch (e) {
@ -159,18 +159,18 @@ export class OpticsMessage {
/**
* Instantiate EXACTLY one message from a receipt.
*
* @param context the {@link OpticsContext} object to use
* @param context the {@link AbacusContext} object to use
* @param nameOrDomain the domain on which the receipt was logged
* @param receipt the receipt
* @returns an array of {@link OpticsMessage} objects
* @returns an array of {@link AbacusMessage} objects
* @throws if there is not EXACTLY 1 dispatch in the receipt
*/
static singleFromReceipt(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
receipt: TransactionReceipt,
): OpticsMessage {
const messages: OpticsMessage[] = OpticsMessage.fromReceipt(
): AbacusMessage {
const messages: AbacusMessage[] = AbacusMessage.fromReceipt(
context,
nameOrDomain,
receipt,
@ -184,46 +184,46 @@ export class OpticsMessage {
/**
* Instantiate one or more messages from a tx hash.
*
* @param context the {@link OpticsContext} object to use
* @param context the {@link AbacusContext} object to use
* @param nameOrDomain the domain on which the receipt was logged
* @param receipt the receipt
* @returns an array of {@link OpticsMessage} objects
* @returns an array of {@link AbacusMessage} objects
* @throws if there is no receipt for the TX
*/
static async fromTransactionHash(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
transactionHash: string,
): Promise<OpticsMessage[]> {
): Promise<AbacusMessage[]> {
const provider = context.mustGetProvider(nameOrDomain);
const receipt = await provider.getTransactionReceipt(transactionHash);
if (!receipt) {
throw new Error(`No receipt for ${transactionHash} on ${nameOrDomain}`);
}
return OpticsMessage.fromReceipt(context, nameOrDomain, receipt);
return AbacusMessage.fromReceipt(context, nameOrDomain, receipt);
}
/**
* Instantiate EXACTLY one message from a transaction has.
*
* @param context the {@link OpticsContext} object to use
* @param context the {@link AbacusContext} object to use
* @param nameOrDomain the domain on which the receipt was logged
* @param receipt the receipt
* @returns an array of {@link OpticsMessage} objects
* @returns an array of {@link AbacusMessage} objects
* @throws if there is no receipt for the TX, or if not EXACTLY 1 dispatch in
* the receipt
*/
static async singleFromTransactionHash(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
transactionHash: string,
): Promise<OpticsMessage> {
): Promise<AbacusMessage> {
const provider = context.mustGetProvider(nameOrDomain);
const receipt = await provider.getTransactionReceipt(transactionHash);
if (!receipt) {
throw new Error(`No receipt for ${transactionHash} on ${nameOrDomain}`);
}
return OpticsMessage.singleFromReceipt(context, nameOrDomain, receipt);
return AbacusMessage.singleFromReceipt(context, nameOrDomain, receipt);
}
/**
@ -321,7 +321,7 @@ export class OpticsMessage {
*
* @returns An array of {@link AnnotatedLifecycleEvent} objects
*/
async events(): Promise<OpticsStatus> {
async events(): Promise<AbacusStatus> {
const events: AnnotatedLifecycleEvent[] = [this.dispatch];
// attempt to get Home update
const homeUpdate = await this.getHomeUpdate();

@ -2,11 +2,11 @@ import { BigNumber } from '@ethersproject/bignumber';
import { arrayify, hexlify } from '@ethersproject/bytes';
import { TransactionReceipt } from '@ethersproject/abstract-provider';
import { ethers } from 'ethers';
import { xapps } from 'optics-ts-interface';
import { BridgeContracts, OpticsContext } from '..';
import { xapps } from '@abacus-network/ts-interface';
import { BridgeContracts, AbacusContext } from '..';
import { ResolvedTokenInfo, TokenIdentifier } from '../tokens';
import { OpticsMessage } from './OpticsMessage';
import { AnnotatedDispatch } from '../events/opticsEvents';
import { AbacusMessage } from './AbacusMessage';
import { AnnotatedDispatch } from '../events/abacusEvents';
const ACTION_LEN = {
identifier: 1,
@ -106,10 +106,10 @@ function parseBody(
}
/**
* The BridgeMessage extends {@link OpticsMessage} with Bridge-specific
* The BridgeMessage extends {@link AbacusMessage} with Bridge-specific
* functionality.
*/
class BridgeMessage extends OpticsMessage {
class BridgeMessage extends AbacusMessage {
readonly token: TokenIdentifier;
readonly fromBridge: BridgeContracts;
readonly toBridge: BridgeContracts;
@ -118,7 +118,7 @@ class BridgeMessage extends OpticsMessage {
* @hideconstructor
*/
constructor(
context: OpticsContext,
context: AbacusContext,
event: AnnotatedDispatch,
token: TokenIdentifier,
callerKnowsWhatTheyAreDoing: boolean,
@ -138,36 +138,36 @@ class BridgeMessage extends OpticsMessage {
/**
* Attempt to instantiate a BridgeMessage from an existing
* {@link OpticsMessage}
* {@link AbacusMessage}
*
* @param context The {@link OpticsContext} to use.
* @param opticsMessage The existing OpticsMessage
* @param context The {@link AbacusContext} to use.
* @param abacusMessage The existing AbacusMessage
* @returns A Bridge message
* @throws if the message cannot be parsed as a bridge message
*/
static fromOpticsMessage(
context: OpticsContext,
opticsMessage: OpticsMessage,
static fromAbacusMessage(
context: AbacusContext,
abacusMessage: AbacusMessage,
): AnyBridgeMessage {
const parsedMessageBody = parseBody(opticsMessage.message.body);
const parsedMessageBody = parseBody(abacusMessage.message.body);
switch (parsedMessageBody.action.type) {
case 'transfer':
return new TransferMessage(
context,
opticsMessage.dispatch,
abacusMessage.dispatch,
parsedMessageBody as ParsedTransferMessage,
);
case 'details':
return new DetailsMessage(
context,
opticsMessage.dispatch,
abacusMessage.dispatch,
parsedMessageBody as ParsedDetailsMessage,
);
case 'requestDetails':
return new RequestDetailsMessage(
context,
opticsMessage.dispatch,
abacusMessage.dispatch,
parsedMessageBody as ParsedRequestDetailsMesasage,
);
}
@ -176,32 +176,32 @@ class BridgeMessage extends OpticsMessage {
/**
* Attempt to instantiate some BridgeMessages from a transaction receipt
*
* @param context The {@link OpticsContext} to use.
* @param context The {@link AbacusContext} to use.
* @param nameOrDomain the domain on which the receipt was logged
* @param receipt The receipt
* @returns an array of {@link BridgeMessage} objects
* @throws if any message cannot be parsed as a bridge message
*/
static fromReceipt(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
receipt: TransactionReceipt,
): AnyBridgeMessage[] {
const opticsMessages: OpticsMessage[] = OpticsMessage.fromReceipt(
const abacusMessages: AbacusMessage[] = AbacusMessage.fromReceipt(
context,
nameOrDomain,
receipt,
);
const bridgeMessages: AnyBridgeMessage[] = [];
for (const opticsMessage of opticsMessages) {
for (const abacusMessage of abacusMessages) {
try {
const bridgeMessage = BridgeMessage.fromOpticsMessage(
const bridgeMessage = BridgeMessage.fromAbacusMessage(
context,
opticsMessage,
abacusMessage,
);
bridgeMessages.push(bridgeMessage);
} catch (e) {
// catch error if OpticsMessage isn't a BridgeMessage
// catch error if AbacusMessage isn't a BridgeMessage
}
}
return bridgeMessages;
@ -210,7 +210,7 @@ class BridgeMessage extends OpticsMessage {
/**
* Attempt to instantiate EXACTLY one BridgeMessage from a transaction receipt
*
* @param context The {@link OpticsContext} to use.
* @param context The {@link AbacusContext} to use.
* @param nameOrDomain the domain on which the receipt was logged
* @param receipt The receipt
* @returns an array of {@link BridgeMessage} objects
@ -218,7 +218,7 @@ class BridgeMessage extends OpticsMessage {
* is not EXACTLY 1 BridgeMessage in the receipt
*/
static singleFromReceipt(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
receipt: TransactionReceipt,
): AnyBridgeMessage {
@ -237,14 +237,14 @@ class BridgeMessage extends OpticsMessage {
* Attempt to instantiate some BridgeMessages from a transaction hash by
* retrieving and parsing the receipt.
*
* @param context The {@link OpticsContext} to use.
* @param context The {@link AbacusContext} to use.
* @param nameOrDomain the domain on which the receipt was logged
* @param transactionHash The transaction hash
* @returns an array of {@link BridgeMessage} objects
* @throws if any message cannot be parsed as a bridge message
*/
static async fromTransactionHash(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
transactionHash: string,
): Promise<AnyBridgeMessage[]> {
@ -260,7 +260,7 @@ class BridgeMessage extends OpticsMessage {
* Attempt to instantiate EXACTLY one BridgeMessages from a transaction hash
* by retrieving and parsing the receipt.
*
* @param context The {@link OpticsContext} to use.
* @param context The {@link AbacusContext} to use.
* @param nameOrDomain the domain on which the receipt was logged
* @param transactionHash The transaction hash
* @returns an array of {@link BridgeMessage} objects
@ -268,7 +268,7 @@ class BridgeMessage extends OpticsMessage {
* not EXACTLY one such message
*/
static async singleFromTransactionHash(
context: OpticsContext,
context: AbacusContext,
nameOrDomain: string | number,
transactionHash: string,
): Promise<AnyBridgeMessage> {
@ -327,7 +327,7 @@ export class TransferMessage extends BridgeMessage {
action: Transfer;
constructor(
context: OpticsContext,
context: AbacusContext,
event: AnnotatedDispatch,
parsed: ParsedTransferMessage,
) {
@ -381,7 +381,7 @@ export class DetailsMessage extends BridgeMessage {
action: Details;
constructor(
context: OpticsContext,
context: AbacusContext,
event: AnnotatedDispatch,
parsed: ParsedDetailsMessage,
) {
@ -419,7 +419,7 @@ export class RequestDetailsMessage extends BridgeMessage {
action: RequestDetails;
constructor(
context: OpticsContext,
context: AbacusContext,
event: AnnotatedDispatch,
parsed: ParsedRequestDetailsMesasage,
) {

@ -1,4 +1,4 @@
export { OpticsMessage } from './OpticsMessage';
export { AbacusMessage } from './AbacusMessage';
export {
TransferMessage,
DetailsMessage,

@ -1,5 +1,5 @@
import { BytesLike } from 'ethers';
import { xapps } from 'optics-ts-interface';
import { xapps } from '@abacus-network/ts-interface';
import wellKnown from './wellKnown';
import testnetWellKnown from './testnetWellKnown';

@ -5,9 +5,9 @@ export {
dev,
testnet,
mainnet,
OpticsContext,
OpticsStatus,
OpticsMessage,
OpticsLifecyleEvent,
AbacusContext,
AbacusStatus,
AbacusMessage,
AbacusLifecyleEvent,
Annotated,
} from './optics';
} from './abacus';

@ -11,7 +11,7 @@ type Provider = ethers.providers.Provider;
* connections under a single roof.
*
* @example
* import {mainnet} from 'optics-provider';
* import {mainnet} from '@abacus-network/sdk';
* mainnet.registerRpcProvider('celo', 'https://forno.celo.org');
* mainnet.registerRpcProvider('polygon', '...');
* mainnet.registerRpcProvider('ethereum', '...');

@ -23,7 +23,7 @@ export function canonizeId(data: BytesLike): Uint8Array {
}
/**
* Converts an Optics ID of 20 or 32 bytes to the corresponding EVM Address.
* Converts an Abacus ID of 20 or 32 bytes to the corresponding EVM Address.
*
* For 32-byte IDs this enforces the EVM convention of using the LAST 20 bytes.
*

@ -0,0 +1,18 @@
{
"extends": "../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/",
"rootDir": "./src/"
},
"exclude": ["./node_modules/", "./dist/", "./src/tmp.ts"],
"include": [
"./src/*.ts",
"src/abacus/*.ts",
"src/abacus/contracts/*.ts",
"src/abacus/domains/*.ts",
"src/abacus/events/*.ts",
"src/abacus/govern/*.ts",
"src/abacus/messages/*.ts",
"src/abacus/tokens/*.ts"
]
}

File diff suppressed because it is too large Load Diff

@ -1,18 +0,0 @@
{
"extends": "../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/",
"rootDir": "./src/"
},
"exclude": ["./node_modules/", "./dist/", "./src/tmp.ts"],
"include": [
"./src/*.ts",
"./src/optics/*.ts",
"./src/optics/contracts/*.ts",
"./src/optics/domains/*.ts",
"./src/optics/events/*.ts",
"./src/optics/govern/*.ts",
"./src/optics/messages/*.ts",
"./src/optics/tokens/*.ts"
]
}
Loading…
Cancel
Save