Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/ctypes/ctypes.module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CType, CTypeService, CTypeDB } from './interfaces/ctype.interfaces'
import Optional from 'typescript-optional'
import * as SDK from '@kiltprotocol/sdk-js'
import { Blockchain, CType as SDKCType, CTypeMetadata, Identity} from '@kiltprotocol/sdk-js'
import { Test } from '@nestjs/testing'
import { CTypesController } from './ctypes.controller'
import { AuthGuard } from '../auth/auth.guard'
Expand All @@ -18,7 +18,7 @@ jest.mock('@kiltprotocol/sdk-js/build/ctype/CType.chain', () => {
})

describe('CType Module', () => {
const SDKCTypeA: SDK.CType = SDK.CType.fromSchema({
const SDKCTypeA: SDKCType = SDKCType.fromSchema({
$schema: 'http://kilt-protocol.org/draft-01/ctype#',
properties: {
name: {
Expand All @@ -32,7 +32,7 @@ describe('CType Module', () => {
title: 'test_ctype',
})

const metaDataA: SDK.CTypeMetadata = {
const metaDataA: CTypeMetadata = {
ctypeHash: SDKCTypeA.hash,
metadata: {
title: { default: 'Test Ctype' },
Expand All @@ -43,7 +43,7 @@ describe('CType Module', () => {
},
}

const SDKCTypeB = SDK.CType.fromSchema({
const SDKCTypeB = SDKCType.fromSchema({
$schema: 'http://kilt-protocol.org/draft-01/ctype#',
properties: {
name: {
Expand All @@ -57,7 +57,7 @@ describe('CType Module', () => {
title: 'another_ctype',
})

const metaDataB: SDK.CTypeMetadata = {
const metaDataB: CTypeMetadata = {
ctypeHash: SDKCTypeB.hash,
metadata: {
title: { default: 'Test Ctype' },
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('CType Module', () => {

beforeAll(
async () =>
(aliceAddress = (await SDK.Identity.buildFromURI('//Alice')).address)
(aliceAddress = (await Identity.buildFromURI('//Alice')).address)
)

beforeEach(async () => {
Expand All @@ -106,7 +106,7 @@ describe('CType Module', () => {
{
provide: 'BlockchainService',
useValue: {
connect: () => new SDK.Blockchain(blockchainApi.__mocked_api),
connect: () => new Blockchain(blockchainApi.__mocked_api),
},
},
],
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('CType Module', () => {

beforeAll(
async () =>
(aliceAddress = (await SDK.Identity.buildFromURI('//Alice')).address)
(aliceAddress = (await Identity.buildFromURI('//Alice')).address)
)

beforeEach(async () => {
Expand Down
11 changes: 3 additions & 8 deletions src/faucet/faucet.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Balance, Identity } from '@kiltprotocol/sdk-js'
import { Balance, Identity, BlockchainUtils } from '@kiltprotocol/sdk-js'
import {
Controller,
Inject,
Expand All @@ -21,10 +21,6 @@ import {
FaucetDropInvalidAddressException,
} from './exceptions'
import { AuthGuard } from '../auth/auth.guard'
import {
IS_IN_BLOCK,
submitSignedTx,
} from '@kiltprotocol/sdk-js/build/blockchain/Blockchain'

const DEFAULT_TOKEN_AMOUNT = 500

Expand Down Expand Up @@ -79,10 +75,9 @@ export class FaucetController {
new BN(DEFAULT_TOKEN_AMOUNT),
0
)
const status = await submitSignedTx(tx, {
resolveOn: IS_IN_BLOCK,
const status = await BlockchainUtils.submitSignedTx(tx, {
resolveOn: BlockchainUtils.IS_IN_BLOCK,
})
console.log(`Status: ${status.isInBlock}`)

return Promise.resolve(status.isInBlock)
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/faucet/faucet.module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jest.mock('@kiltprotocol/sdk-js/build/balance/Balance.chain', () => {
}
})

jest.mock('@kiltprotocol/sdk-js/build/blockchain/Blockchain', () => {
jest.mock('@kiltprotocol/sdk-js/build/blockchain/Blockchain.utils', () => {
return {
__esModule: true,
submitSignedTx: jest.fn().mockImplementation(
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Faucet Module', () => {
const mockedMakeTransfer = require('@kiltprotocol/sdk-js/build/balance/Balance.chain')
.makeTransfer

const mockedsubmitSignedTx = require('@kiltprotocol/sdk-js/build/blockchain/Blockchain')
const mockedsubmitSignedTx = require('@kiltprotocol/sdk-js/build/blockchain/Blockchain.utils')
.submitSignedTx

const fakeFaucetService: FaucetService = {
Expand Down
20 changes: 10 additions & 10 deletions test/contacts.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { INestApplication } from '@nestjs/common'
import { Test } from '@nestjs/testing'
import request from 'supertest'
import * as sdk from '@kiltprotocol/sdk-js'
import { MockMongooseModule, mongodbInstance } from './MockMongooseModule'
import {
ContactsService,
Contact,
} from '../src/contacts/interfaces/contacts.interfaces'
import { ContactsModule } from '../src/contacts/contacts.module'
import { IDidDocumentSigned } from '@kiltprotocol/sdk-js/build/did/Did'
import Did, { IDidDocumentSigned } from '@kiltprotocol/sdk-js/build/did/Did'
import { Identity } from '@kiltprotocol/sdk-js'

describe('contacts endpoint (e2e)', () => {
let app: INestApplication
let idAlice: sdk.Identity
let idBob: sdk.Identity
let idAlice: Identity
let idBob: Identity
let contactsService: ContactsService
let contactA: Contact
let contactB: Contact
Expand All @@ -27,8 +27,8 @@ describe('contacts endpoint (e2e)', () => {
await app.init()

contactsService = app.get('ContactsService')
idAlice = await sdk.Identity.buildFromURI('//Alice')
idBob = await sdk.Identity.buildFromURI('//Bob')
idAlice = await Identity.buildFromURI('//Alice')
idBob = await Identity.buildFromURI('//Bob')

contactA = {
publicIdentity: idAlice.getPublicIdentity(),
Expand Down Expand Up @@ -91,8 +91,8 @@ describe('contacts endpoint (e2e)', () => {
})

it('gets did by contact address', async () => {
const didAlice = sdk.Did.signDidDocument(
sdk.Did.fromIdentity(idAlice).createDefaultDidDocument(),
const didAlice = Did.signDidDocument(
Did.fromIdentity(idAlice).createDefaultDidDocument(),
idAlice
)
await contactsService.add({ ...contactA, did: didAlice })
Expand Down Expand Up @@ -198,8 +198,8 @@ describe('contacts endpoint (e2e)', () => {
let didAlice: IDidDocumentSigned

beforeAll(() => {
didAlice = sdk.Did.signDidDocument(
sdk.Did.fromIdentity(idAlice).createDefaultDidDocument(),
didAlice = Did.signDidDocument(
Did.fromIdentity(idAlice).createDefaultDidDocument(),
idAlice
)
})
Expand Down
12 changes: 6 additions & 6 deletions test/ctypes.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { INestApplication } from '@nestjs/common'
import { Test } from '@nestjs/testing'
import request from 'supertest'
import * as sdk from '@kiltprotocol/sdk-js'
import { MockMongooseModule, mongodbInstance } from './MockMongooseModule'
import { CTypesModule } from '../src/ctypes/ctypes.module'
import { CType, CTypeService } from '../src/ctypes/interfaces/ctype.interfaces'
import { BlockchainModule } from '../src/blockchain/blockchain.module'
import { CType as SDKCType, Identity } from '@kiltprotocol/sdk-js'

jest.mock('@kiltprotocol/sdk-js/build/ctype/CType.chain', () => {
return {
Expand All @@ -18,10 +18,10 @@ jest.mock(

describe('ctypes endpoint (e2e)', () => {
let app: INestApplication
let idAlice: sdk.Identity
let idAlice: Identity
let ctypeService: CTypeService

const kiltCTypeA = sdk.CType.fromSchema({
const kiltCTypeA = SDKCType.fromSchema({
$schema: 'http://kilt-protocol.org/draft-01/ctype#',
properties: {
name: {
Expand All @@ -48,7 +48,7 @@ describe('ctypes endpoint (e2e)', () => {
},
}

const kiltCTypeB = sdk.CType.fromSchema({
const kiltCTypeB = SDKCType.fromSchema({
$schema: 'http://kilt-protocol.org/draft-01/ctype#',
properties: {
name: {
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('ctypes endpoint (e2e)', () => {
await app.init()

ctypeService = app.get('CTypeService')
idAlice = await sdk.Identity.buildFromURI('//Alice')
idAlice = await Identity.buildFromURI('//Alice')
}, 30000)

beforeEach(async () => {
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('ctypes endpoint (e2e)', () => {
mockedGetOwner.mockResolvedValue('new-owner')
const cTypeRecordWithOwner = {
...cTypeRecordA,
cType: sdk.CType.fromSchema(kiltCTypeA.schema, idAlice.address),
cType: SDKCType.fromSchema(kiltCTypeA.schema, idAlice.address),
}
await request(app.getHttpServer())
.post(`/ctype`)
Expand Down
4 changes: 2 additions & 2 deletions test/faucet.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jest.mock('@kiltprotocol/sdk-js/build/balance/Balance.chain', () => {
}
})

jest.mock('@kiltprotocol/sdk-js/build/blockchain/Blockchain', () => {
jest.mock('@kiltprotocol/sdk-js/build/blockchain/Blockchain.utils', () => {
return {
__esModules: true,

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('faucet endpoint (e2e)', () => {

beforeEach(async () => {
await faucetService.reset()
require('@kiltprotocol/sdk-js/build/blockchain/Blockchain').submitSignedTx.mockResolvedValue(
require('@kiltprotocol/sdk-js/build/blockchain/Blockchain.utils').submitSignedTx.mockResolvedValue(
{ isInBlock: true }
)
require('@kiltprotocol/sdk-js/build/balance/Balance.chain').makeTransfer.mockResolvedValue(
Expand Down