Skip to content

Commit eac65fa

Browse files
authored
Merge pull request #767 from LIT-Protocol/feature/lit-4132-js-sdk-naga-add-naga-dev-support
feat: add naga dev support
2 parents bc74bf0 + 3d1bd01 commit eac65fa

File tree

9 files changed

+57
-42
lines changed

9 files changed

+57
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@cosmjs/stargate": "0.30.1",
4444
"@dotenvx/dotenvx": "^1.6.4",
4545
"@lit-protocol/accs-schemas": "^0.0.22",
46-
"@lit-protocol/contracts": "^0.0.74",
46+
"@lit-protocol/contracts": "^0.0.86",
4747
"@metamask/eth-sig-util": "5.0.2",
4848
"@mysten/sui.js": "^0.37.1",
4949
"@openagenda/verror": "^3.1.4",

packages/constants/src/lib/constants/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ export const LIT_NETWORK = {
984984
DatilDev: 'datil-dev',
985985
DatilTest: 'datil-test',
986986
Datil: 'datil',
987+
NagaDev: 'naga-dev',
987988
Custom: 'custom',
988989
} as const;
989990
/**
@@ -1018,6 +1019,7 @@ export type LIT_NETWORK_VALUES = (typeof LIT_NETWORK)[keyof typeof LIT_NETWORK];
10181019
export const RPC_URL_BY_NETWORK: { [key in LIT_NETWORK_VALUES]: string } = {
10191020
'datil-dev': LIT_RPC.CHRONICLE_YELLOWSTONE,
10201021
'datil-test': LIT_RPC.CHRONICLE_YELLOWSTONE,
1022+
'naga-dev': LIT_RPC.CHRONICLE_YELLOWSTONE,
10211023
datil: LIT_RPC.CHRONICLE_YELLOWSTONE,
10221024
custom: LIT_RPC.LOCAL_ANVIL,
10231025
};
@@ -1030,6 +1032,7 @@ export const RELAYER_URL_BY_NETWORK: {
10301032
} = {
10311033
'datil-dev': 'https://datil-dev-relayer.getlit.dev',
10321034
'datil-test': 'https://datil-test-relayer.getlit.dev',
1035+
'naga-dev': 'https://naga-dev-relayer.getlit.dev',
10331036
datil: 'https://datil-relayer.getlit.dev',
10341037
custom: 'http://localhost:3000',
10351038
};
@@ -1043,6 +1046,7 @@ export const METAMASK_CHAIN_INFO_BY_NETWORK: Record<
10431046
> = {
10441047
'datil-dev': METAMASK_CHAIN_INFO.yellowstone,
10451048
'datil-test': METAMASK_CHAIN_INFO.yellowstone,
1049+
'naga-dev': METAMASK_CHAIN_INFO.yellowstone,
10461050
datil: METAMASK_CHAIN_INFO.yellowstone,
10471051
custom: METAMASK_CHAIN_INFO.yellowstone,
10481052
};
@@ -1059,6 +1063,7 @@ export const HTTP_BY_NETWORK: Record<
10591063
> = {
10601064
'datil-dev': HTTPS,
10611065
'datil-test': HTTPS,
1066+
'naga-dev': HTTPS,
10621067
datil: HTTPS,
10631068
custom: HTTP, // default, can be changed by config
10641069
};
@@ -1072,6 +1077,7 @@ export const CENTRALISATION_BY_NETWORK: Record<
10721077
> = {
10731078
'datil-dev': 'centralised',
10741079
'datil-test': 'decentralised',
1080+
'naga-dev': 'centralised',
10751081
datil: 'decentralised',
10761082
custom: 'unknown',
10771083
} as const;
@@ -1223,6 +1229,7 @@ export const LIT_NETWORKS: { [key in LIT_NETWORK_VALUES]: string[] } = {
12231229
'datil-dev': [],
12241230
'datil-test': [],
12251231
datil: [],
1232+
'naga-dev': [],
12261233
custom: [],
12271234
};
12281235

packages/constants/src/lib/constants/mappers.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import depd from 'depd';
22

3-
import { datilDev, datilTest, datil } from '@lit-protocol/contracts';
3+
import { datilDev, datilTest, datil, _nagaDev } from '@lit-protocol/contracts';
44

55
import { LIT_NETWORK_VALUES } from './constants';
66

@@ -13,13 +13,13 @@ export const NETWORK_CONTEXT_BY_NETWORK: {
1313
[key in LIT_NETWORK_VALUES]:
1414
| typeof datilDev
1515
| typeof datilTest
16-
| typeof datil;
16+
| typeof datil
17+
| typeof _nagaDev;
1718
} = {
1819
'datil-dev': datilDev,
1920
'datil-test': datilTest,
2021
datil: datil,
21-
22-
// just use datil dev abis for custom
22+
'naga-dev': _nagaDev,
2323
custom: datilDev,
2424
} as const;
2525

@@ -29,8 +29,9 @@ export const GLOBAL_OVERWRITE_IPFS_CODE_BY_NETWORK: {
2929
'datil-dev': false,
3030
'datil-test': false,
3131
datil: false,
32+
'naga-dev': false,
3233
custom: false,
33-
};
34+
} as const;
3435

3536
/**
3637
* Product IDs used for price feed and node selection

packages/contracts-sdk/src/lib/contracts-sdk.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ import {
8282
import { calculateUTCMidnightExpiration, requestsToKilosecond } from './utils';
8383
import { ValidatorStruct } from './types';
8484

85+
// FIXME: this should be dynamically set, but we only have 1 net atm.
86+
const REALM_ID = 1;
87+
8588
// const DEFAULT_RPC = 'https://lit-protocol.calderachain.xyz/replica-http';
8689
// const DEFAULT_READ_RPC = 'https://lit-protocol.calderachain.xyz/replica-http';
8790

@@ -148,6 +151,7 @@ export class LitContracts {
148151
'Multisender',
149152
'LITToken',
150153
'StakingBalances',
154+
'PriceFeed',
151155
];
152156

153157
static logger: Logger = LogManager.Instance.get('contract-sdk');
@@ -810,6 +814,7 @@ export class LitContracts {
810814
'❌ Could not get staking contract address from contract context'
811815
);
812816
}
817+
813818
return new ethers.Contract(
814819
stakingContract.address,
815820
stakingContract.abi ?? StakingData.abi,
@@ -932,6 +937,12 @@ export class LitContracts {
932937
environment
933938
);
934939
break;
940+
case 'PriceFeed':
941+
address = await resolverContract['getContract'](
942+
await resolverContract['PRICE_FEED_CONTRACT'](),
943+
environment
944+
);
945+
break;
935946
}
936947

937948
return address;
@@ -1041,6 +1052,11 @@ export class LitContracts {
10411052
addresses.Multisender.address = contract.address;
10421053
addresses.Multisender.abi = contract?.abi ?? MultisenderData.abi;
10431054
break;
1055+
case 'PriceFeed':
1056+
addresses.PriceFeed = {};
1057+
addresses.PriceFeed.address = contract.address;
1058+
addresses.PriceFeed.abi = contract?.abi;
1059+
break;
10441060
}
10451061
}
10461062

@@ -1165,7 +1181,9 @@ export class LitContracts {
11651181
);
11661182

11671183
const [epochInfo, minNodeCount, activeUnkickedValidatorStructs] =
1168-
await stakingContract['getActiveUnkickedValidatorStructsAndCounts']();
1184+
await stakingContract['getActiveUnkickedValidatorStructsAndCounts'](
1185+
REALM_ID
1186+
);
11691187

11701188
const typedEpochInfo: EpochInfo = {
11711189
epochLength: ethers.BigNumber.from(epochInfo[0]).toNumber(),
@@ -1208,12 +1226,12 @@ export class LitContracts {
12081226
// networks are all the nodes we know from the `getActiveUnkickedValidatorStructsAndCounts` function, but we also want to sort it by price feed
12091227
// which we need to call the price feed contract
12101228
const priceFeedInfo = await LitContracts.getPriceFeedInfo({
1229+
realmId: REALM_ID,
12111230
litNetwork,
12121231
networkContext,
12131232
rpcUrl,
12141233
nodeProtocol,
12151234
});
1216-
12171235
// example of Network to Price Map: {
12181236
// 'http://xxx:7470': 100, <-- lowest price
12191237
// 'http://yyy:7471': 300, <-- highest price
@@ -1262,11 +1280,13 @@ export class LitContracts {
12621280
* }>}
12631281
*/
12641282
public static getPriceFeedInfo = async ({
1283+
realmId,
12651284
litNetwork,
12661285
networkContext,
12671286
rpcUrl,
12681287
productIds, // Array of product IDs
12691288
}: {
1289+
realmId: number;
12701290
litNetwork: LIT_NETWORKS_KEYS;
12711291
networkContext?: LitContractContext | LitContractResolverContext;
12721292
rpcUrl?: string;
@@ -1296,6 +1316,7 @@ export class LitContracts {
12961316
);
12971317

12981318
const nodesForRequest = await priceFeedContract['getNodesForRequest'](
1319+
realmId,
12991320
productIds
13001321
);
13011322

packages/event-listener/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scripts": {
2727
"generate-lit-actions": "yarn node ./esbuild.config.js"
2828
},
29-
"version": "7.0.3",
29+
"version": "8.0.0-alpha.0",
3030
"main": "./dist/src/index.js",
3131
"typings": "./dist/src/index.d.ts"
3232
}

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ import type {
135135
SuccessNodePromises,
136136
} from '@lit-protocol/types';
137137

138+
// FIXME: this should be dynamically set, but we only have 1 net atm.
139+
const REALM_ID = 1;
138140
export class LitNodeClientNodeJs
139141
extends LitCore
140142
implements LitClientSessionManager, ILitNodeClient
@@ -1993,6 +1995,7 @@ export class LitNodeClientNodeJs
19931995
if (params.getNewPrices) {
19941996
log(`Getting new prices from the contract`);
19951997
const priceFeedInfo = await LitContracts.getPriceFeedInfo({
1998+
realmId: REALM_ID,
19961999
litNetwork: this.config.litNetwork,
19972000
networkContext: this.config.contractContext,
19982001
rpcUrl: this.config.rpcUrl,

packages/types/src/lib/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ export type LITCosmosChain = LITChainRequiredProps & {
112112
*/
113113
export type LITChain<T> = Record<string, T>;
114114

115-
export type LIT_NETWORKS_KEYS = 'datil-dev' | 'datil-test' | 'datil' | 'custom';
115+
export type LIT_NETWORKS_KEYS =
116+
| 'datil-dev'
117+
| 'datil-test'
118+
| 'datil'
119+
| 'naga-dev'
120+
| 'custom';
116121

117122
export type SymmetricKey = Uint8Array | string | CryptoKey | BufferSource;
118123
export type EncryptedSymmetricKey = string | Uint8Array | any;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.83"
3+
targets = ["wasm32-unknown-unknown"]

yarn.lock

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,10 +3020,10 @@
30203020
dependencies:
30213021
ajv "^8.12.0"
30223022

3023-
"@lit-protocol/contracts@^0.0.74":
3024-
version "0.0.74"
3025-
resolved "https://registry.yarnpkg.com/@lit-protocol/contracts/-/contracts-0.0.74.tgz#e726a9190c86b10cc6df3a392cd04d19057be27d"
3026-
integrity sha512-8uV038gzBp7ew7a4884SVt9Zhu8CtiTb+A8dKNnByxVoT1kFt4O4DmsaniV8p9AGjNR13IWfpU1NFChmPHVIpQ==
3023+
"@lit-protocol/contracts@^0.0.86":
3024+
version "0.0.86"
3025+
resolved "https://registry.yarnpkg.com/@lit-protocol/contracts/-/contracts-0.0.86.tgz#adec861d0b775995523483b2fa5f4baf83d735a9"
3026+
integrity sha512-JtSjXwClG9wietQMERhSN1NqYas8JjQbso0FA9BAyv4svS3ejeKVwWcXUUvHPK9gDWPVhBzmvMNaB7ooR5UpBw==
30273027

30283028
"@ljharb/resumer@~0.0.1":
30293029
version "0.0.1"
@@ -21429,7 +21429,7 @@ string-length@^4.0.1:
2142921429
char-regex "^1.0.2"
2143021430
strip-ansi "^6.0.0"
2143121431

21432-
"string-width-cjs@npm:string-width@^4.2.0":
21432+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
2143321433
version "4.2.3"
2143421434
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
2143521435
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -21447,15 +21447,6 @@ string-width@^1.0.1:
2144721447
is-fullwidth-code-point "^1.0.0"
2144821448
strip-ansi "^3.0.0"
2144921449

21450-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
21451-
version "4.2.3"
21452-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
21453-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
21454-
dependencies:
21455-
emoji-regex "^8.0.0"
21456-
is-fullwidth-code-point "^3.0.0"
21457-
strip-ansi "^6.0.1"
21458-
2145921450
string-width@^2.0.0, string-width@^2.1.0:
2146021451
version "2.1.1"
2146121452
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
@@ -21577,7 +21568,7 @@ stringify-package@^1.0.1:
2157721568
resolved "https://registry.yarnpkg.com/stringify-package/-/stringify-package-1.0.1.tgz#e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85"
2157821569
integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==
2157921570

21580-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
21571+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
2158121572
version "6.0.1"
2158221573
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
2158321574
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -21605,13 +21596,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
2160521596
dependencies:
2160621597
ansi-regex "^4.1.0"
2160721598

21608-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
21609-
version "6.0.1"
21610-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
21611-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
21612-
dependencies:
21613-
ansi-regex "^5.0.1"
21614-
2161521599
strip-ansi@^7.0.1:
2161621600
version "7.1.0"
2161721601
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -23749,7 +23733,7 @@ wordwrap@^1.0.0:
2374923733
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
2375023734
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
2375123735

23752-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
23736+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
2375323737
version "7.0.0"
2375423738
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
2375523739
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -23784,15 +23768,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
2378423768
string-width "^4.1.0"
2378523769
strip-ansi "^6.0.0"
2378623770

23787-
wrap-ansi@^7.0.0:
23788-
version "7.0.0"
23789-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
23790-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
23791-
dependencies:
23792-
ansi-styles "^4.0.0"
23793-
string-width "^4.1.0"
23794-
strip-ansi "^6.0.0"
23795-
2379623771
wrap-ansi@^8.0.1, wrap-ansi@^8.1.0:
2379723772
version "8.1.0"
2379823773
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)