diff --git a/.changeset/selfish-bugs-teach.md b/.changeset/selfish-bugs-teach.md new file mode 100644 index 00000000..7348bd47 --- /dev/null +++ b/.changeset/selfish-bugs-teach.md @@ -0,0 +1,5 @@ +--- +'@bnb-chain/greenfield-js-sdk': patch +--- + +fix: All class use injectable diff --git a/examples/nextjs/src/client/index.ts b/examples/nextjs/src/client/index.ts index 59699810..c5059d99 100644 --- a/examples/nextjs/src/client/index.ts +++ b/examples/nextjs/src/client/index.ts @@ -6,6 +6,14 @@ export const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID), { 'https://unpkg.com/@bnb-chain/greenfield-zk-crypto@0.0.3-alpha.0/dist/node/zk-crypto.wasm', }); +export const client2 = Client.create('xx222x', String('346345'), { + zkCryptoUrl: + 'https://unpkg.com/@bnb-chain/greenfield-zk-crypto@0.0.3-alpha.0/dist/node/zk-crypto.wasm', +}); + +console.log(client); +console.log(client2); + export const getSps = async () => { const sps = await client.sp.getStorageProviders(); const finalSps = (sps ?? []).filter((v: any) => v.endpoint.includes('nodereal')); diff --git a/examples/nextjs/src/components/query/index.tsx b/examples/nextjs/src/components/query/index.tsx index 4e63b53d..25683d9d 100644 --- a/examples/nextjs/src/components/query/index.tsx +++ b/examples/nextjs/src/components/query/index.tsx @@ -1,4 +1,4 @@ -import { client } from '@/client'; +import { client, client2 } from '@/client'; import { ACCOUNT_PRIVATEKEY } from '@/config/env'; import { getOffchainAuthKeys } from '@/utils/offchainAuth'; import { Long } from '@bnb-chain/greenfield-js-sdk'; @@ -20,6 +20,10 @@ export const QueryComponent = () => { const account = await client.account.getAccount(address); console.log('account', account); + + const account2 = await client2.account.getAccount(address); + + console.log('account2', account2); }} > get account diff --git a/packages/chain-sdk/package.json b/packages/chain-sdk/package.json index 9b576026..10156d7a 100644 --- a/packages/chain-sdk/package.json +++ b/packages/chain-sdk/package.json @@ -73,7 +73,7 @@ "lodash.sortby": "^4.7.0", "long": "^5.2.1", "reflect-metadata": "^0.1.13", - "tsyringe": "^4.7.0" + "tsyringe": "^4.8.0" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/packages/chain-sdk/src/api/account.ts b/packages/chain-sdk/src/api/account.ts index 80a4b47e..0e098191 100644 --- a/packages/chain-sdk/src/api/account.ts +++ b/packages/chain-sdk/src/api/account.ts @@ -12,13 +12,9 @@ import { QueryBalanceResponse, } from '@bnb-chain/greenfield-cosmos-types/cosmos/bank/v1beta1/query'; import { MsgMultiSend, MsgSend } from '@bnb-chain/greenfield-cosmos-types/cosmos/bank/v1beta1/tx'; -import { - QueryPaymentAccountRequest, - QueryPaymentAccountResponse, - QueryPaymentAccountsByOwnerResponse, -} from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/query'; +import { QueryPaymentAccountsByOwnerResponse } from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/query'; import { MsgCreatePaymentAccount } from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { MsgCreatePaymentAccountTypeUrl, MsgMultiSendTypeUrl, @@ -60,7 +56,7 @@ export interface IAccount { multiTransfer(address: string, msg: MsgMultiSend): Promise; } -@singleton() +@injectable() export class Account implements IAccount { constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} diff --git a/packages/chain-sdk/src/api/basic.ts b/packages/chain-sdk/src/api/basic.ts index bc2a5f27..7ff0a7ed 100644 --- a/packages/chain-sdk/src/api/basic.ts +++ b/packages/chain-sdk/src/api/basic.ts @@ -6,7 +6,7 @@ import { ServiceClientImpl as tdServiceClientImpl, } from '@bnb-chain/greenfield-cosmos-types/cosmos/base/tendermint/v1beta1/query'; import Long from 'long'; -import { container, singleton } from 'tsyringe'; +import { container, injectable } from 'tsyringe'; import { RpcQueryClient } from '../clients/queryclient'; export interface IBasic { @@ -45,7 +45,7 @@ export interface IBasic { GetLatestValidatorSet(request: GetLatestValidatorSetRequest): Promise; } -@singleton() +@injectable() export class Basic implements IBasic { private rpcQueryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/bucket.ts b/packages/chain-sdk/src/api/bucket.ts index c97fdebe..c94e5877 100644 --- a/packages/chain-sdk/src/api/bucket.ts +++ b/packages/chain-sdk/src/api/bucket.ts @@ -31,25 +31,6 @@ import { MsgCreateBucketSDKTypeEIP712 } from '@/messages/greenfield/storage/MsgC import { MsgDeleteBucketSDKTypeEIP712 } from '@/messages/greenfield/storage/MsgDeleteBucket'; import { MsgMigrateBucketSDKTypeEIP712 } from '@/messages/greenfield/storage/MsgMigrateBucket'; import { MsgUpdateBucketInfoSDKTypeEIP712 } from '@/messages/greenfield/storage/MsgUpdateBucketInfo'; -import type { - GetBucketMetaRequest, - GetBucketMetaResponse, - GetUserBucketsRequest, - GetUserBucketsResponse, - IQuotaProps, - ListBucketReadRecordRequest, - ListBucketReadRecordResponse, - ListBucketsByIDsRequest, - ListBucketsByIDsResponse, - MigrateBucketApprovalRequest, - MigrateBucketApprovalResponse, - ReadQuotaRequest, - SpResponse, - ListBucketsByPaymentAccountRequest, - CreateBucketApprovalRequest, - CreateBucketApprovalResponse, - ListBucketsByPaymentAccountResponse, -} from '../types/sp'; import { decodeObjectFromHexString } from '@/utils/encoding'; import { isValidAddress, isValidBucketName, isValidUrl } from '@/utils/s3'; import { UInt64Value } from '@bnb-chain/greenfield-cosmos-types/greenfield/common/wrapper'; @@ -79,7 +60,7 @@ import { bytesFromBase64 } from '@bnb-chain/greenfield-cosmos-types/helpers'; import { Headers } from 'cross-fetch'; import { bytesToUtf8, hexToBytes } from 'ethereum-cryptography/utils'; import Long from 'long'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { GRNToString, MsgCreateBucketTypeUrl, @@ -91,6 +72,25 @@ import { } from '..'; import { RpcQueryClient } from '../clients/queryclient'; import { AuthType, SpClient } from '../clients/spclient/spClient'; +import type { + CreateBucketApprovalRequest, + CreateBucketApprovalResponse, + GetBucketMetaRequest, + GetBucketMetaResponse, + GetUserBucketsRequest, + GetUserBucketsResponse, + IQuotaProps, + ListBucketReadRecordRequest, + ListBucketReadRecordResponse, + ListBucketsByIDsRequest, + ListBucketsByIDsResponse, + ListBucketsByPaymentAccountRequest, + ListBucketsByPaymentAccountResponse, + MigrateBucketApprovalRequest, + MigrateBucketApprovalResponse, + ReadQuotaRequest, + SpResponse, +} from '../types/sp'; import { Sp } from './sp'; import { Storage } from './storage'; @@ -181,7 +181,7 @@ export interface IBucket { ): Promise>; } -@singleton() +@injectable() export class Bucket implements IBucket { constructor( @inject(delay(() => TxClient)) private txClient: TxClient, diff --git a/packages/chain-sdk/src/api/challenge.ts b/packages/chain-sdk/src/api/challenge.ts index 9b687fca..c7f8193a 100644 --- a/packages/chain-sdk/src/api/challenge.ts +++ b/packages/chain-sdk/src/api/challenge.ts @@ -7,7 +7,7 @@ import { QueryParamsResponse, } from '@bnb-chain/greenfield-cosmos-types/greenfield/challenge/query'; import { MsgAttest, MsgSubmit } from '@bnb-chain/greenfield-cosmos-types/greenfield/challenge/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { MsgAttestTypeUrl, MsgSubmitTypeUrl, TxResponse } from '..'; import { RpcQueryClient } from '../clients/queryclient'; @@ -34,7 +34,7 @@ export interface IChallenge { params(): Promise; } -@singleton() +@injectable() export class Challenge implements IChallenge { private queryClient = container.resolve(RpcQueryClient); constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} diff --git a/packages/chain-sdk/src/api/crosschain.ts b/packages/chain-sdk/src/api/crosschain.ts index 8178a42f..bae79efa 100644 --- a/packages/chain-sdk/src/api/crosschain.ts +++ b/packages/chain-sdk/src/api/crosschain.ts @@ -1,3 +1,4 @@ +import { TxClient } from '@/clients/txClient'; import { MsgClaimSDKTypeEIP712 } from '@/messages/cosmos/oracle/MsgClaim'; import { MsgTransferOutSDKTypeEIP712 } from '@/messages/greenfield/bridge/MsgTransferOut'; import { MsgMirrorBucketSDKTypeEIP712 } from '@/messages/greenfield/storage/MsgMirrorBucket'; @@ -20,7 +21,7 @@ import { MsgMirrorGroup, MsgMirrorObject, } from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { MsgClaimTypeUrl, MsgMirrorBucketTypeUrl, @@ -29,9 +30,7 @@ import { MsgTransferOutTypeUrl, TxResponse, } from '..'; -import { Basic } from './basic'; import { RpcQueryClient } from '../clients/queryclient'; -import { TxClient } from '@/clients/txClient'; export interface ICrossChain { /** @@ -83,7 +82,7 @@ export interface ICrossChain { getParams(): Promise; } -@singleton() +@injectable() export class CrossChain implements ICrossChain { constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} private queryClient: RpcQueryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/distribution.ts b/packages/chain-sdk/src/api/distribution.ts index c73560db..a7733332 100644 --- a/packages/chain-sdk/src/api/distribution.ts +++ b/packages/chain-sdk/src/api/distribution.ts @@ -5,7 +5,7 @@ import { MsgWithdrawValidatorCommissionResponse, } from '@bnb-chain/greenfield-cosmos-types/cosmos/distribution/v1beta1/tx'; import { Coin } from '@cosmjs/proto-signing'; -import { container } from 'tsyringe'; +import { container, injectable } from 'tsyringe'; import { Basic } from './basic'; import { RpcQueryClient } from '../clients/queryclient'; export interface IDistribution { @@ -41,6 +41,7 @@ export interface IDistribution { ): Promise; } +@injectable() export class Distribution implements IDistribution { private basic: Basic = container.resolve(Basic); private queryClient: RpcQueryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/feegrant.ts b/packages/chain-sdk/src/api/feegrant.ts index d0fafbe6..66525e8b 100644 --- a/packages/chain-sdk/src/api/feegrant.ts +++ b/packages/chain-sdk/src/api/feegrant.ts @@ -13,7 +13,7 @@ import { } from '@bnb-chain/greenfield-cosmos-types/cosmos/feegrant/v1beta1/tx'; import { base64FromBytes } from '@bnb-chain/greenfield-cosmos-types/helpers'; import { arrayify } from '@ethersproject/bytes'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { encodeToHex, IGrantAllowance, @@ -37,7 +37,7 @@ export interface IFeeGrant { getAllowences(request: QueryAllowancesRequest): Promise; } -@singleton() +@injectable() export class FeeGrant implements IFeeGrant { constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} private queryClient: RpcQueryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/gashub.ts b/packages/chain-sdk/src/api/gashub.ts index 422cfa1b..0f064d9b 100644 --- a/packages/chain-sdk/src/api/gashub.ts +++ b/packages/chain-sdk/src/api/gashub.ts @@ -1,9 +1,9 @@ -import { container, singleton } from 'tsyringe'; import { QueryMsgGasParamsRequest, QueryMsgGasParamsResponse, QueryParamsResponse, } from '@bnb-chain/greenfield-cosmos-types/cosmos/gashub/v1beta1/query'; +import { container, injectable } from 'tsyringe'; import { RpcQueryClient } from '../clients/queryclient'; export interface IGashub { @@ -12,7 +12,7 @@ export interface IGashub { getMsgGasParams(request: QueryMsgGasParamsRequest): Promise; } -@singleton() +@injectable() export class Gashub implements IGashub { private queryClient: RpcQueryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/group.ts b/packages/chain-sdk/src/api/group.ts index 4330ed42..6f9b398a 100644 --- a/packages/chain-sdk/src/api/group.ts +++ b/packages/chain-sdk/src/api/group.ts @@ -23,7 +23,7 @@ import { MsgUpdateGroupExtra, MsgUpdateGroupMember, } from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { fromTimestamp, MsgCreateGroupTypeUrl, @@ -98,7 +98,7 @@ export interface IGroup { ): Promise; } -@singleton() +@injectable() export class Group implements IGroup { constructor( @inject(delay(() => TxClient)) private txClient: TxClient, diff --git a/packages/chain-sdk/src/api/objectt.ts b/packages/chain-sdk/src/api/objectt.ts index f6194f12..d47ad1db 100644 --- a/packages/chain-sdk/src/api/objectt.ts +++ b/packages/chain-sdk/src/api/objectt.ts @@ -55,7 +55,7 @@ import { bytesFromBase64 } from '@bnb-chain/greenfield-cosmos-types/helpers'; import { hexlify } from '@ethersproject/bytes'; import { Headers } from 'cross-fetch'; import { bytesToUtf8, hexToBytes, utf8ToBytes } from 'ethereum-cryptography/utils'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { GRNToString, MsgCancelCreateObjectTypeUrl, @@ -172,7 +172,7 @@ export interface IObject { // TODO: getObjectStatusFromSP } -@singleton() +@injectable() export class Objectt implements IObject { constructor( @inject(delay(() => TxClient)) private txClient: TxClient, diff --git a/packages/chain-sdk/src/api/offchainauth.ts b/packages/chain-sdk/src/api/offchainauth.ts index 9fc55cbd..1c0bb6e9 100644 --- a/packages/chain-sdk/src/api/offchainauth.ts +++ b/packages/chain-sdk/src/api/offchainauth.ts @@ -9,7 +9,7 @@ import { updateSpsPubKey, } from '@/offchainauth'; import { hexlify } from '@ethersproject/bytes'; -import { singleton } from 'tsyringe'; +import { injectable } from 'tsyringe'; import { convertTimeStampToDate, getUtcZeroTimestamp, SpResponse } from '..'; import { IGenOffChainAuthKeyPairAndUpload, @@ -27,7 +27,7 @@ export interface IOffChainAuth { ): Promise>; } -@singleton() +@injectable() export class OffChainAuth implements IOffChainAuth { public async genOffChainAuthKeyPairAndUpload( { sps, address, domain, expirationMs, chainId }: IGenOffChainAuthKeyPairAndUpload, diff --git a/packages/chain-sdk/src/api/payment.ts b/packages/chain-sdk/src/api/payment.ts index 1e9c334a..60a35158 100644 --- a/packages/chain-sdk/src/api/payment.ts +++ b/packages/chain-sdk/src/api/payment.ts @@ -7,7 +7,6 @@ import { TxClient } from '@/clients/txClient'; import { MsgDepositSDKTypeEIP712 } from '@/messages/greenfield/payment/MsgDeposit'; import { MsgDisableRefundSDKTypeEIP712 } from '@/messages/greenfield/payment/MsgDisableRefund'; import { MsgWithdrawSDKTypeEIP712 } from '@/messages/greenfield/payment/MsgWithdraw'; -import { ListUserPaymentAccountsResquest } from '../types/sp/ListUserPaymentAccounts'; import { QueryAutoSettleRecordsRequest, QueryAutoSettleRecordsResponse, @@ -37,16 +36,20 @@ import { MsgDisableRefund, MsgWithdraw, } from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { - METHOD_GET, MsgDepositTypeUrl, MsgDisableRefundTypeUrl, MsgWithdrawTypeUrl, NORMAL_ERROR_CODE, + SpResponse, TxResponse, } from '..'; import { RpcQueryClient } from '../clients/queryclient'; +import { + ListUserPaymentAccountsResponse, + ListUserPaymentAccountsResquest, +} from '../types/sp/ListUserPaymentAccounts'; import { Sp } from './sp'; export interface IPayment { @@ -110,10 +113,10 @@ export interface IPayment { listUserPaymentAccounts( params: ListUserPaymentAccountsResquest, authType: AuthType, - ): Promise; + ): Promise>; } -@singleton() +@injectable() export class Payment implements IPayment { constructor( @inject(delay(() => TxClient)) private txClient: TxClient, diff --git a/packages/chain-sdk/src/api/proposal.ts b/packages/chain-sdk/src/api/proposal.ts index 08a53998..af262469 100644 --- a/packages/chain-sdk/src/api/proposal.ts +++ b/packages/chain-sdk/src/api/proposal.ts @@ -2,7 +2,7 @@ import { TxClient } from '@/clients/txClient'; import { MsgVoteSDKTypeEIP712 } from '@/messages/cosmos/gov/MsgVote'; import { voteOptionToJSON } from '@bnb-chain/greenfield-cosmos-types/cosmos/gov/v1/gov'; import { MsgVote } from '@bnb-chain/greenfield-cosmos-types/cosmos/gov/v1/tx'; -import { delay, inject, singleton } from 'tsyringe'; +import { delay, inject, injectable } from 'tsyringe'; import { MsgVoteTypeUrl, TxResponse } from '..'; export interface IProposal { @@ -12,7 +12,7 @@ export interface IProposal { voteProposal(msg: MsgVote): Promise; } -@singleton() +@injectable() export class Proposal implements IProposal { constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} diff --git a/packages/chain-sdk/src/api/sp.ts b/packages/chain-sdk/src/api/sp.ts index 73d9ae0c..a5a60c6e 100644 --- a/packages/chain-sdk/src/api/sp.ts +++ b/packages/chain-sdk/src/api/sp.ts @@ -24,16 +24,16 @@ import { QueryStorageProviderMaintenanceRecordsResponse, } from '@bnb-chain/greenfield-cosmos-types/greenfield/sp/query'; import { Status, StorageProvider } from '@bnb-chain/greenfield-cosmos-types/greenfield/sp/types'; -import { container, singleton } from 'tsyringe'; +import { container, injectable } from 'tsyringe'; import type { - SpResponse, + ListGroupsMembersRequest, ListGroupsMembersResponse, ListGroupsResponse, - ListUserGroupsResponse, ListGroupsResquest, - ListGroupsMembersRequest, + ListUserGroupsResponse, ListUserGroupsResquest, ListUserOwnedGroupsRequest, + SpResponse, VerifyPermissionRequest, VerifyPermissionResponse, } from '..'; @@ -102,7 +102,7 @@ export interface ISp { verifyPermission(params: VerifyPermissionRequest): Promise>; } -@singleton() +@injectable() export class Sp implements ISp { private bucket = container.resolve(Bucket); private queryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/storage.ts b/packages/chain-sdk/src/api/storage.ts index 9e58e108..a781ff3a 100644 --- a/packages/chain-sdk/src/api/storage.ts +++ b/packages/chain-sdk/src/api/storage.ts @@ -21,7 +21,7 @@ import { MsgDeletePolicy, MsgPutPolicy, } from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { fromTimestamp, MsgDeletePolicyTypeUrl, MsgPutPolicyTypeUrl, TxResponse } from '..'; import { RpcQueryClient } from '../clients/queryclient'; @@ -53,7 +53,7 @@ export interface IStorage { queryGroupsExistById(request: QueryGroupsExistByIdRequest): Promise; } -@singleton() +@injectable() export class Storage implements IStorage { constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} private queryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/validator.ts b/packages/chain-sdk/src/api/validator.ts index d4060268..a0441296 100644 --- a/packages/chain-sdk/src/api/validator.ts +++ b/packages/chain-sdk/src/api/validator.ts @@ -6,7 +6,7 @@ import { QueryValidatorsResponse, } from '@bnb-chain/greenfield-cosmos-types/cosmos/staking/v1beta1/query'; import { MsgEditValidator } from '@bnb-chain/greenfield-cosmos-types/cosmos/staking/v1beta1/tx'; -import { container, delay, inject, singleton } from 'tsyringe'; +import { container, delay, inject, injectable } from 'tsyringe'; import { MsgEditValidatorTypeUrl, TxResponse } from '..'; export interface IValidator { @@ -25,7 +25,7 @@ export interface IValidator { editValidator(address: string, msg: MsgEditValidator): Promise; } -@singleton() +@injectable() export class Validator implements IValidator { constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {} private queryClient: RpcQueryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/api/virtualGroup.ts b/packages/chain-sdk/src/api/virtualGroup.ts index a8d95ee2..7857b3f2 100644 --- a/packages/chain-sdk/src/api/virtualGroup.ts +++ b/packages/chain-sdk/src/api/virtualGroup.ts @@ -9,7 +9,7 @@ import { QueryGlobalVirtualGroupResponse, QueryParamsResponse, } from '@bnb-chain/greenfield-cosmos-types/greenfield/virtualgroup/query'; -import { container, singleton } from 'tsyringe'; +import { container, injectable } from 'tsyringe'; import { RpcQueryClient } from '../clients/queryclient'; export interface IVirtualGroup { @@ -32,7 +32,7 @@ export interface IVirtualGroup { ): Promise; } -@singleton() +@injectable() export class VirtualGroup implements IVirtualGroup { private queryClient = container.resolve(RpcQueryClient); diff --git a/packages/chain-sdk/src/client.ts b/packages/chain-sdk/src/client.ts index cdb70cd7..776f1711 100644 --- a/packages/chain-sdk/src/client.ts +++ b/packages/chain-sdk/src/client.ts @@ -1,27 +1,26 @@ import 'reflect-metadata'; -import { container, injectable } from 'tsyringe'; +import { container } from 'tsyringe'; import { Account, IAccount } from './api/account'; +import { Basic, IBasic } from './api/basic'; import { Bucket, IBucket } from './api/bucket'; import { Challenge, IChallenge } from './api/challenge'; import { CrossChain, ICrossChain } from './api/crosschain'; import { Distribution, IDistribution } from './api/distribution'; import { FeeGrant, IFeeGrant } from './api/feegrant'; +import { Gashub, IGashub } from './api/gashub'; import { Group, IGroup } from './api/group'; import { IObject, Objectt } from './api/objectt'; +import { IOffChainAuth, OffChainAuth } from './api/offchainauth'; import { IPayment, Payment } from './api/payment'; +import { IProposal, Proposal } from './api/proposal'; import { ISp, Sp } from './api/sp'; -import { IOffChainAuth, OffChainAuth } from './api/offchainauth'; import { IStorage, Storage } from './api/storage'; -import { Basic, IBasic } from './api/basic'; -import { Gashub, IGashub } from './api/gashub'; -import { RpcQueryClient } from './clients/queryclient'; +import { Validator } from './api/validator'; import { IVirtualGroup, VirtualGroup } from './api/virtualGroup'; +import { RpcQueryClient } from './clients/queryclient'; import { ISpClient, SpClient } from './clients/spclient/spClient'; -import { Validator } from './api/validator'; -import { IProposal, Proposal } from './api/proposal'; import { ITxClient, TxClient } from './clients/txClient'; -@injectable() export class Client { /** * @rpcUrl string diff --git a/packages/chain-sdk/src/clients/spclient/spClient.ts b/packages/chain-sdk/src/clients/spclient/spClient.ts index d376cadf..706364c8 100644 --- a/packages/chain-sdk/src/clients/spclient/spClient.ts +++ b/packages/chain-sdk/src/clients/spclient/spClient.ts @@ -7,8 +7,7 @@ import { } from '@/clients/spclient/auth'; import { parseError } from '@/clients/spclient/spApis/parseError'; import { ReqMeta } from '@/types/auth'; -import { Headers } from 'cross-fetch'; -import { singleton } from 'tsyringe'; +import { injectable } from 'tsyringe'; import { getGetObjectMetaInfo } from './spApis/getObject'; import { getPutObjectMetaInfo } from './spApis/putObject'; @@ -59,7 +58,7 @@ export interface ISpClient { }; } -@singleton() +@injectable() export class SpClient implements ISpClient { public async callApi( url: string, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0efb87c0..34ba549f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -257,8 +257,8 @@ importers: specifier: ^0.1.13 version: 0.1.13 tsyringe: - specifier: ^4.7.0 - version: 4.7.0 + specifier: ^4.8.0 + version: 4.8.0 devDependencies: '@jest/globals': specifier: ^29.5.0 @@ -11154,8 +11154,8 @@ packages: tslib: 1.14.1 typescript: 4.9.5 - /tsyringe@4.7.0: - resolution: {integrity: sha512-ncFDM1jTLsok4ejMvSW5jN1VGPQD48y2tfAR0pdptWRKYX4bkbqPt92k7KJ5RFJ1KV36JEs/+TMh7I6OUgj74g==} + /tsyringe@4.8.0: + resolution: {integrity: sha512-YB1FG+axdxADa3ncEtRnQCFq/M0lALGLxSZeVNbTU8NqhOVc51nnv2CISTcvc1kyv6EGPtXVr0v6lWeDxiijOA==} engines: {node: '>= 6.0.0'} dependencies: tslib: 1.14.1