Skip to content

Commit

Permalink
Revert "wip"
Browse files Browse the repository at this point in the history
This reverts commit f900e15.
  • Loading branch information
Josh Long committed Dec 18, 2023
1 parent f900e15 commit 4ffeecd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 86 deletions.
75 changes: 27 additions & 48 deletions packages/contracts-sdk/src/lib/contracts-sdk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BigNumberish, BytesLike, ethers } from 'ethers';
import { hexToDec, decToHex, intToIP } from './hex2dec';
import bs58 from 'bs58';
import { isBrowser, isNode } from '@lit-protocol/misc';
import { AuthMethod, LitContractContext } from '@lit-protocol/types';
import { isBrowser, isNode, log } from '@lit-protocol/misc';
import { AuthMethod } from '@lit-protocol/types';

let CID: any;
try {
Expand Down Expand Up @@ -101,7 +101,6 @@ export class LitContracts {
isPKP: boolean = false;
debug: boolean = false;
network: 'cayenne';
customContext?: LitContractContext;

static logger: Logger = LogManager.Instance.get('contract-sdk');
// ----- autogen:declares:start -----
Expand Down Expand Up @@ -166,7 +165,6 @@ export class LitContracts {
// make the constructor args optional
constructor(args?: {
provider?: ethers.providers.JsonRpcProvider | any;
customContext?: LitContracts;
rpcs?: string[] | any;
rpc?: string | any;
signer?: ethers.Signer | any;
Expand All @@ -179,7 +177,6 @@ export class LitContracts {
network?: 'cayenne';
}) {
// this.provider = args?.provider;
this.customContext = args?.customContext;
this.rpc = args?.rpc;
this.rpcs = args?.rpcs;
this.signer = args?.signer;
Expand Down Expand Up @@ -543,8 +540,7 @@ export class LitContracts {
};

public static async getStakingContract(
network: 'cayenne' | 'internalDev' | 'manzano' | 'habanero' | 'custom' | 'localhost',
context?: LitContracts
network: 'cayenne' | 'internalDev' | 'manzano' | 'habanero' | 'custom' | 'localhost'
) {
let manifest = await LitContracts._resolveContractContext(network);

Expand All @@ -567,86 +563,69 @@ export class LitContracts {
}

public static async getContractAddresses(
network: 'cayenne' | 'custom' | 'localhost',
context?: LitContractContext
network: 'cayenne' | 'custom' | 'localhost'
) {

let data
if (context) {
let reMap = [];
let keys = Object.keys(context);
for (const key of keys) {
context[key].name = key;
reMap.push(context[key].name = key);
}
data = {
contractData: reMap
};
} else {
data = await LitContracts._resolveContractContext(network);
}


const data = await LitContracts._resolveContractContext(network);
// Destructure the data for easier access
const { config, data: contractData } = data;
const addresses: any = {};
for (const contract of contractData) {
switch (contract.name) {
case 'Allowlist':
addresses.Allowlist = {};
addresses.Allowlist.address = contract.contracts[0].address_hash ?? contract.address;
addresses.Allowlist.abi = contract.contracts[0].ABI ?? AllowlistData.abi;
addresses.Allowlist.address = contract.contracts[0].address_hash;
addresses.Allowlist.abi = contract.contracts[0].ABI;
break;
case 'PKPHelper':
addresses.PKPHelper = {};
addresses.PKPHelper.address = contract.contracts[0].address_hash ?? contract.address;
addresses.PKPHelper.abi = contract.contracts[0].ABI ?? PKPHelperData.abi;
addresses.PKPHelper.address = contract.contracts[0].address_hash;
addresses.PKPHelper.abi = contract.contracts[0].ABI;
break;
case 'PKPNFT':
addresses.PKPNFT = {};
addresses.PKPNFT.address = contract.contracts[0].address_hash ?? contract.address;
addresses.PKPNFT.abi = contract.contracts[0].ABI ?? PKPNFTData.abi;
addresses.PKPNFT.address = contract.contracts[0].address_hash;
addresses.PKPNFT.abi = contract.contracts[0].ABI;
break;
case 'Staking':
addresses.Staking = {};
addresses.Staking.address = contract.contracts[0].address_hash ?? contract.address;
addresses.Staking.abi = contract.contracts[0].ABI ?? StakingData.abi;
addresses.Staking.address = contract.contracts[0].address_hash;
addresses.Staking.abi = contract.contracts[0].ABI;
break;
case 'RateLimitNFT':
addresses.RateLimitNFT = {};
addresses.RateLimitNFT.address = contract.contracts[0].address_hash ?? contract.address;
addresses.RateLimitNFT.abi = contract.contracts[0].ABI ?? RateLimitNFTData.abi;
addresses.RateLimitNFT.address = contract.contracts[0].address_hash;
addresses.RateLimitNFT.abi = contract.contracts[0].ABI;
break;
case 'PKPPermissions':
addresses.PKPPermissions = {};
addresses.PKPPermissions.address = contract.contracts[0].address_hash ?? contract.address;
addresses.PKPPermissions.abi = contract.contracts[0].ABI ?? PKPPermissionsData.abi;
addresses.PKPPermissions.address = contract.contracts[0].address_hash;
addresses.PKPPermissions.abi = contract.contracts[0].ABI;
break;
case 'PKPNFTMetadata':
addresses.PKPNFTMetadata = {};
addresses.PKPNFTMetadata.address = contract.contracts[0].address_hash ?? contract.address;
addresses.PKPNFTMetadata.abi = contract.contracts[0].ABI ?? PKPNFTMetadataData.abi;
addresses.PKPNFTMetadata.address = contract.contracts[0].address_hash;
addresses.PKPNFTMetadata.abi = contract.contracts[0].ABI;
break;
case 'PubkeyRouter':
addresses.PubkeyRouter = {};
addresses.PubkeyRouter.address = contract.contracts[0].address_hash ?? contract.address;
addresses.PubkeyRouter.abi = contract.contracts[0].ABI ?? PubkeyRouterData.abi;
addresses.PubkeyRouter.address = contract.contracts[0].address_hash;
addresses.PubkeyRouter.abi = contract.contracts[0].ABI;
break;
case 'LITToken':
addresses.LITToken = {};
addresses.LITToken.address = contract.contracts[0].address_hash ?? contract.address;
addresses.LITToken.abi = contract.contracts[0].ABI ?? LITTokenData.abi;
addresses.LITToken.address = contract.contracts[0].address_hash;
addresses.LITToken.abi = contract.contracts[0].ABI;
break;
case 'StakingBalances':
addresses.StakingBalances = {};
addresses.StakingBalances.address =
contract.contracts[0].address_hash ?? contract.address;
addresses.StakingBalances.abi = contract.contracts[0].ABI ?? StakingBalancesData.abi;
contract.contracts[0].address_hash;
addresses.StakingBalances.abi = contract.contracts[0].ABI;
break;
case 'Multisender':
addresses.Multisender = {};
addresses.Multisender.address = contract.contracts[0].address_hash ?? contract.address;
addresses.Multisender.abi = contract.contracts[0].ABI ?? MultisenderData.abi;
addresses.Multisender.address = contract.contracts[0].address_hash;
addresses.Multisender.abi = contract.contracts[0].ABI;
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
JsonHandshakeResponse,
JsonPkpSignRequest,
KV,
LitContractContext,
LitNodeClientConfig,
MultipleAccessControlConditions,
NodeAttestation,
Expand Down Expand Up @@ -74,7 +73,6 @@ export class LitCore {
networkPubKeySet: string | null;
hdRootPubkeys: string[] | null;
latestBlockhash: string | null;
contractContext?: LitContractContext | null;

// ========== Constructor ==========
constructor(args: any[LitNodeClientConfig | CustomNetwork | any]) {
Expand Down
8 changes: 5 additions & 3 deletions packages/types/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
AcceptedFileType,
AccessControlConditions,
Chain,
ClaimProcessor,
ClaimResult,
ConditionType,
EncryptedSymmetricKey,
EvmContractConditions,
IRelayAuthStatus,
JsonRequest,
LIT_NETWORKS_KEYS,
LitContractContext,
Resolver,
MintCallback,
SolRpcConditions,
SymmetricKey,
UnifiedAccessControlConditions,
Expand All @@ -22,9 +23,11 @@ import {
ISessionCapabilityObject,
LitResourceAbilityRequest,
} from '@lit-protocol/auth-helpers';
import { BytesLike } from 'ethers';

// @ts-ignore
import * as JSZip from 'jszip/dist/jszip.js';
import { AuthMethodType } from './enums';

export interface AccsOperatorParams {
operator: string;
Expand Down Expand Up @@ -224,7 +227,6 @@ export interface LitNodeClientConfig {
debug: boolean;
bootstrapUrls: Array<string>;
litNetwork: LIT_NETWORKS_KEYS;
contracts?: LitContractContext | Resolver,
connectTimeout: number;
checkNodeAttestation: boolean;
defaultAuthCallback?: (authSigParams: AuthCallbackParams) => Promise<AuthSig>;
Expand Down
33 changes: 0 additions & 33 deletions packages/types/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AuthMethodType } from './enums';
import * as ethers from 'ethers';
import { StakingBalances } from '../../../../dist/packages/contracts-sdk/src/abis/StakingBalances.sol/StakingBalances';
import {
AuthMethod,
LitRelayConfig,
Expand Down Expand Up @@ -181,35 +180,3 @@ export type ClaimResult<T = ClaimProcessor> = {
authMethodType: AuthMethodType;
pubkey: string;
} & (T extends 'relay' ? LitRelayConfig : { signer: ethers.Signer });

export type LitContract = {
address: string,
abi?: any;
name?: string;
};

/**
* Defines a set of contract metadata for bootstrapping
* network context and interfacing with contracts on Chroncile blockchain
*
*/
export type LitContractContext = {
[index:string]: LitContract;

Allowlist: LitContract,
LITToken: LitContract,
Multisender: LitContract,
PKPHelper: LitContract,
PKPNFT: LitContract,
PKPNFTMetadata: LitContract,
PKPPermissions: LitContract,
PubkeyRouter: LitContract,
RateLitmitNFT: LitContract,
Staking: LitContract,
StakingBalances: LitContract
};

/**
*
*/
export type Resolver = ethers.Contract;

0 comments on commit 4ffeecd

Please sign in to comment.