Skip to content

Commit af8b814

Browse files
authored
Merge pull request #3925 from connext/main
Testnet-prod sync
2 parents c7bb0f8 + 30b7fb3 commit af8b814

File tree

132 files changed

+71207
-2132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+71207
-2132
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## Next Release
44

5+
## Amarok 2.0.0-alpha.1
6+
57
- [sdk] Uses browser provider for calls, if detected
68
- [sdk] Added optional flag `checkFastLiquidity` to `calculateAmountReceived`
79
- [contracts] Added HARD token to testnet
10+
- [contracts] Log proposal transactions
811

912
## Amarok 2.0.0-alpha.0
1013

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@
5151
"resolutions": {
5252
"@nomiclabs/hardhat-ethers": "https://registry.npmjs.org/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.3.0-beta.10.tgz"
5353
},
54-
"packageManager": "yarn@3.3.1",
54+
"packageManager": "yarn@3.5.0",
5555
"stableVersion": "0.1.25"
5656
}

packages/adapters/cache/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-adapters-cache",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "adapter for handling communication with Redis cache for nxtp protocol",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/adapters/database/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-adapters-database",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "adapter for handling communication with Redis cache for nxtp protocol",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/adapters/database/src/client.ts

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
RouterDailyTVL,
2121
SlippageUpdate,
2222
XTransferMessageStatus,
23+
Asset,
2324
} from "@connext/nxtp-utils";
2425
import { Pool } from "pg";
2526
import * as db from "zapatos/db";
@@ -547,6 +548,23 @@ export const saveRouterBalances = async (
547548
}
548549
};
549550

551+
export const saveAssets = async (assets: Asset[], _pool?: Pool | db.TxnClientForRepeatableRead): Promise<void> => {
552+
const poolToUse = _pool ?? pool;
553+
const dbAssets: s.assets.Insertable[] = assets.map((asset) => {
554+
return {
555+
key: asset.key,
556+
id: asset.id,
557+
decimal: asset.decimal as any,
558+
local: asset.localAsset,
559+
adopted: asset.adoptedAsset,
560+
canonical_id: asset.canonicalId,
561+
canonical_domain: asset.canonicalDomain,
562+
domain: asset.domain,
563+
};
564+
});
565+
await db.upsert("assets", dbAssets, ["canonical_id", "domain"]).run(poolToUse);
566+
};
567+
550568
export const transaction = async (
551569
callback: (client: db.TxnClientForRepeatableRead) => Promise<void>,
552570
): Promise<void> => {

packages/adapters/database/src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
StableSwapPoolEvent,
1616
RouterDailyTVL,
1717
SlippageUpdate,
18+
Asset,
1819
} from "@connext/nxtp-utils";
1920
import { Pool } from "pg";
2021
import { TxnClientForRepeatableRead } from "zapatos/db";
@@ -65,6 +66,7 @@ import {
6566
updateExecuteSimulationData,
6667
getPendingTransfersByMessageStatus,
6768
getMessageByLeaf,
69+
saveAssets,
6870
} from "./client";
6971

7072
export * as db from "zapatos/db";
@@ -100,6 +102,7 @@ export type Database = {
100102
_pool?: Pool | TxnClientForRepeatableRead,
101103
) => Promise<XTransfer[]>;
102104
saveRouterBalances: (routerBalances: RouterBalance[], _pool?: Pool | TxnClientForRepeatableRead) => Promise<void>;
105+
saveAssets: (assets: Asset[], _pool?: Pool | TxnClientForRepeatableRead) => Promise<void>;
103106
saveMessages: (messages: XMessage[], _pool?: Pool | TxnClientForRepeatableRead) => Promise<void>;
104107
getRootMessages: (
105108
processed: boolean | undefined,
@@ -254,6 +257,7 @@ export const getDatabase = async (databaseUrl: string, logger: Logger): Promise<
254257
getTransfersWithDestinationPending,
255258
getCompletedTransfersByMessageHashes,
256259
saveRouterBalances,
260+
saveAssets,
257261
saveMessages,
258262
getRootMessages,
259263
saveSentRootMessages,

packages/adapters/database/test/client.spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
updateSlippage,
6565
getPendingTransfersByMessageStatus,
6666
getMessageRootsFromIndex,
67+
saveAssets,
6768
} from "../src/client";
6869

6970
describe("Database client", () => {
@@ -1121,6 +1122,24 @@ describe("Database client", () => {
11211122
expect(queryRes.rows[0].processed).to.eq(false);
11221123
});
11231124

1125+
it("should save assets", async () => {
1126+
const assets = [mock.entity.asset(), mock.entity.asset(), mock.entity.asset()];
1127+
await saveAssets(assets, pool);
1128+
let queryRes = await pool.query("SELECT * FROM assets");
1129+
assets.forEach((asset) => {
1130+
expect(queryRes.rows).to.deep.include({
1131+
local: asset.localAsset,
1132+
adopted: asset.adoptedAsset,
1133+
domain: asset.domain,
1134+
key: asset.key,
1135+
id: asset.id,
1136+
decimal: asset.decimal,
1137+
canonical_id: asset.canonicalId,
1138+
canonical_domain: asset.canonicalDomain,
1139+
});
1140+
});
1141+
});
1142+
11241143
it("should get pending transfers by message status", async () => {
11251144
const originDomain = "1337";
11261145
const transfers: XTransfer[] = [

packages/adapters/relayer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-adapters-relayer",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "adapter for handling communication with relayer",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/adapters/subgraph/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-adapters-subgraph",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "adapter for subgraph interaction of nxtp protocol",
55
"main": "dist/src/index.js",
66
"types": "dist/src/index.d.ts",

packages/adapters/subgraph/src/lib/operations/queries.ts

+12
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,18 @@ export const getRouterQuery = (prefix: string, router: string): string => {
436436
`;
437437
};
438438

439+
export const getAssetsQuery = (prefix: string): string => {
440+
const queryString = `
441+
${prefix}_assets {
442+
${ASSET_ENTITY}
443+
}`;
444+
return gql`
445+
query GetAssets {
446+
${queryString}
447+
}
448+
`;
449+
};
450+
439451
export const getAssetByLocalQuery = (prefix: string, local: string): string => {
440452
const queryString = `
441453
${prefix}_assets(where: { id: "${local}" }) {

packages/adapters/subgraph/src/reader.ts

+11
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
import {
5858
getAggregatedRootsByDomainQuery,
5959
getAssetsByLocalsQuery,
60+
getAssetsQuery,
6061
getPoolEventsQuery,
6162
getPropagatedRootsQuery,
6263
getRelayerFeesIncreasesQuery,
@@ -254,6 +255,16 @@ export class SubgraphReader {
254255
return !!router?.id;
255256
}
256257

258+
public async getAssets(domain: string): Promise<Asset[]> {
259+
const { execute, getPrefixForDomain } = getHelpers();
260+
const prefix = getPrefixForDomain(domain);
261+
262+
const query = getAssetsQuery(prefix);
263+
const response = await execute(query);
264+
const assets: Asset[] = [...response.values()].map((v) => v.flat()).flat();
265+
return assets.map((asset) => ({ ...asset, domain }));
266+
}
267+
257268
/**
258269
* Gets the asset by the local address on the specific domain
259270
* @param domain - The domain you're going to get the asset on

packages/adapters/txservice/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-txservice",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "Robust transaction sending service for a wallet configured across multiple chains. Will bump gas and reattempt transactions as needed",
55
"author": "Connext",
66
"license": "MIT",

packages/adapters/watcher/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-adapters-watcher",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "adapter for watcher related calls, monitoring, and functionality",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/adapters/web3signer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-adapters-web3signer",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "adapter for subgraph interaction of nxtp protocol",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/agents/cartographer/poller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/cartographer-poller",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "",
55
"types": "dist/index.d.ts",
66
"files": [

packages/agents/cartographer/poller/src/bindings/routers/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { createLoggingContext, jsonifyError, NxtpError } from "@connext/nxtp-uti
22

33
import { AppContext } from "../../shared";
44
import { updateRouters, updateDailyRouterTvl } from "../../lib/operations";
5+
import { updateAssets } from "../../lib/operations/routers";
56

67
export const bindRouters = async (context: AppContext) => {
78
const { logger } = context;
89
const { requestContext, methodContext } = createLoggingContext(bindRouters.name);
910
try {
1011
logger.debug("Bind routers polling loop start", requestContext, methodContext);
1112
await updateRouters();
13+
await updateAssets();
1214
await updateDailyRouterTvl();
1315
logger.debug("Bind routers polling loop complete", requestContext, methodContext);
1416
} catch (err: unknown) {

packages/agents/cartographer/poller/src/lib/operations/routers.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createLoggingContext, RouterDailyTVL, SubgraphQueryByTimestampMetaParams } from "@connext/nxtp-utils";
1+
import { Asset, createLoggingContext, RouterDailyTVL, SubgraphQueryByTimestampMetaParams } from "@connext/nxtp-utils";
22

33
import { getContext } from "../../shared";
44

@@ -35,6 +35,31 @@ export const updateRouters = async () => {
3535
}
3636
};
3737

38+
export const updateAssets = async () => {
39+
const {
40+
adapters: { subgraph, database },
41+
logger,
42+
domains,
43+
} = getContext();
44+
const { requestContext, methodContext } = createLoggingContext(updateAssets.name);
45+
46+
const assets: Asset[] = [];
47+
for (const domain of domains) {
48+
const offset = await database.getCheckPoint("asset_" + domain);
49+
const limit = 100;
50+
logger.debug("Retrieving assets", requestContext, methodContext, {
51+
domain: domain,
52+
offset: offset,
53+
limit: limit,
54+
});
55+
56+
const _assets = await subgraph.getAssets(domain);
57+
assets.push(..._assets);
58+
}
59+
await database.saveAssets(assets);
60+
logger.debug("Saved assets", requestContext, methodContext, { assets: assets.length });
61+
};
62+
3863
export const updateDailyRouterTvl = async () => {
3964
const {
4065
adapters: { subgraph, database },

packages/agents/lighthouse/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/lighthouse",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/agents/lighthouse/test/globalTestHook.ts

-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export const mochaHooks = {
6666
sendOutboundRootCtxMock = mock.sendOuboundRootCtx();
6767
stub(SendOutboundRootFns, "getContext").returns(sendOutboundRootCtxMock);
6868

69-
getBestProviderMock = stub(Mockable, "getBestProvider").resolves("http://test.rpc.com");
70-
7169
sendWithRelayerWithBackupStub = stub(Mockable, "sendWithRelayerWithBackup").resolves({
7270
taskId: mockTaskId,
7371
relayerType: RelayerType.Mock,

packages/agents/relayer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-relayer",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "Generic relayer agent for Amarok",
55
"author": "Connext",
66
"license": "MIT",

packages/agents/router/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-router",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/agents/sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/sdk",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "Client-side package for interacting with the NXTP protocol for crosschain packages",
55
"author": "Connext",
66
"license": "MIT",

packages/agents/sequencer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-sequencer",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "Sequencer for Amarok, previously auctioneer",
55
"author": "Connext",
66
"license": "MIT",

packages/agents/watcher/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connext/nxtp-watcher",
3-
"version": "2.0.0-alpha.0",
3+
"version": "2.0.0-alpha.1",
44
"description": "",
55
"types": "dist/index.d.ts",
66
"files": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
"function onMessageReceived(address,uint32,bytes) payable"
3+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[
2+
"constructor(uint32,uint32,address,address,address,uint32)",
3+
"error Connector__processMessage_notUsed()",
4+
"error ProposedOwnable__onlyOwner_notOwner()",
5+
"error ProposedOwnable__onlyProposed_notProposedOwner()",
6+
"error ProposedOwnable__ownershipDelayElapsed_delayNotElapsed()",
7+
"error ProposedOwnable__proposeNewOwner_invalidProposal()",
8+
"error ProposedOwnable__proposeNewOwner_noOwnershipChange()",
9+
"error ProposedOwnable__renounceOwnership_invalidProposal()",
10+
"error ProposedOwnable__renounceOwnership_noProposal()",
11+
"event MessageProcessed(bytes,address)",
12+
"event MessageSent(bytes,bytes,address)",
13+
"event MirrorConnectorUpdated(address,address)",
14+
"event NewConnector(uint32 indexed,uint32 indexed,address,address,address)",
15+
"event OwnershipProposed(address indexed)",
16+
"event OwnershipTransferred(address indexed,address indexed)",
17+
"function AMB() view returns (address)",
18+
"function DOMAIN() view returns (uint32)",
19+
"function MIRROR_DOMAIN() view returns (uint32)",
20+
"function ROOT_MANAGER() view returns (address)",
21+
"function acceptProposedOwner()",
22+
"function delay() view returns (uint256)",
23+
"function mirrorConnector() view returns (address)",
24+
"function onMessageReceived(address,uint32,bytes) payable",
25+
"function owner() view returns (address)",
26+
"function processMessage(bytes)",
27+
"function proposeNewOwner(address)",
28+
"function proposed() view returns (address)",
29+
"function proposedTimestamp() view returns (uint256)",
30+
"function renounceOwnership()",
31+
"function renounced() view returns (bool)",
32+
"function sendMessage(bytes,bytes) payable",
33+
"function setMirrorConnector(address)",
34+
"function verifySender(address) returns (bool)"
35+
]

0 commit comments

Comments
 (0)