Skip to content

Commit

Permalink
fix(cheqd): make cosmos payer seed optional (openwallet-foundation#1547)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Martin Auer <[email protected]>
  • Loading branch information
TimoGlastra authored and auer-martin committed Dec 4, 2023
1 parent 7315cbd commit fb4d0fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/cheqd/src/CheqdModule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CheqdModuleConfigOptions } from './CheqdModuleConfig'
import type { AgentContext, DependencyManager, Module } from '@aries-framework/core'

import { AgentConfig } from '@aries-framework/core'
import { AgentConfig, Buffer } from '@aries-framework/core'

import { CheqdModuleConfig } from './CheqdModuleConfig'
import { CheqdLedgerService } from './ledger'
Expand All @@ -25,6 +25,11 @@ export class CheqdModule implements Module {
dependencyManager.registerInstance(CheqdModuleConfig, this.config)

dependencyManager.registerSingleton(CheqdLedgerService)

// Cheqd module needs Buffer to be available globally
// If it is not available yet, we overwrite it with the
// Buffer implementation from AFJ
global.Buffer = global.Buffer || Buffer
}

public async initialize(agentContext: AgentContext): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/cheqd/src/CheqdModuleConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface CheqdModuleConfigOptions {

export interface NetworkConfig {
rpcUrl?: string
cosmosPayerSeed: string
cosmosPayerSeed?: string
network: string
}

Expand Down
6 changes: 3 additions & 3 deletions packages/cheqd/src/ledger/CheqdLedgerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SignInfo } from '@cheqd/ts-proto/cheqd/did/v2'
import type { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2'
import type { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing'

import { injectable } from '@aries-framework/core'
import { AriesFrameworkError, injectable } from '@aries-framework/core'
import { createCheqdSDK, DIDModule, ResourceModule, CheqdNetwork } from '@cheqd/sdk'

import { CheqdModuleConfig } from '../CheqdModuleConfig'
Expand Down Expand Up @@ -42,8 +42,8 @@ export class CheqdLedgerService {
network.sdk = await createCheqdSDK({
modules: [DIDModule as unknown as AbstractCheqdSDKModule, ResourceModule as unknown as AbstractCheqdSDKModule],
rpcUrl: network.rpcUrl,
wallet: await network.cosmosPayerWallet.catch(() => {
throw new Error(`[did-provider-cheqd]: valid cosmosPayerSeed is required`)
wallet: await network.cosmosPayerWallet.catch((error) => {
throw new AriesFrameworkError(`Error initializing cosmos payer wallet: ${error.message}`, { cause: error })
}),
})
}
Expand Down

0 comments on commit fb4d0fb

Please sign in to comment.