Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dev-protocol/dev-kit-js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.11.2
Choose a base ref
...
head repository: dev-protocol/dev-kit-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.11.3
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Jan 27, 2022

  1. Copy the full SHA
    6d29a4c View commit details
  2. Merge pull request #753 from dev-protocol/market-name

    add name func to market contract
    Akira-Taniguchi authored Jan 27, 2022
    Copy the full SHA
    e6ab508 View commit details
  3. 5.11.3

    Akira-Taniguchi committed Jan 27, 2022
    Copy the full SHA
    32e7b6d View commit details
Showing with 63 additions and 2 deletions.
  1. +6 −1 lib/l2/market/index.spec.ts
  2. +3 −0 lib/l2/market/index.ts
  3. +37 −0 lib/l2/market/name.spec.ts
  4. +16 −0 lib/l2/market/name.ts
  5. +1 −1 package.json
7 changes: 6 additions & 1 deletion lib/l2/market/index.spec.ts
Original file line number Diff line number Diff line change
@@ -3,13 +3,15 @@ import { createMarketContract, MarketContract } from '.'
import { createSchemaCaller } from '../../ethereum/market/schema'
import { createVoteCaller } from '../../ethereum/market/vote'
import { createAuthenticateCaller } from './authenticate'
import { createNameCaller } from './name'
import { createBehaviorCaller } from '../../ethereum/market/behavior'
import { createGetAuthenticatedPropertiesCaller } from './getAuthenticatedProperties'
import { marketAbi } from './abi'

jest.mock('../../ethereum/market/schema')
jest.mock('../../ethereum/market/vote')
jest.mock('./authenticate')
jest.mock('./name')
jest.mock('../../ethereum/market/behavior')
jest.mock('./getAuthenticatedProperties')

@@ -25,7 +27,9 @@ describe('market/index.ts', () => {
;(createGetAuthenticatedPropertiesCaller as jest.Mock).mockImplementation(
(contract) => contract
)

;(createNameCaller as jest.Mock).mockImplementation(
(contract) => contract
)
describe('createMarketContract', () => {
it('check return object', () => {
const host = 'localhost'
@@ -41,6 +45,7 @@ describe('market/index.ts', () => {
schema: createSchemaCaller(contract),
authenticate: createAuthenticateCaller(contract, provider),
behavior: createBehaviorCaller(contract),
name: createNameCaller(contract),
getAuthenticatedProperties:
createGetAuthenticatedPropertiesCaller(contract),
}
3 changes: 3 additions & 0 deletions lib/l2/market/index.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import { marketAbi } from './abi'
import { createSchemaCaller } from '../../ethereum/market/schema'
import { createVoteCaller } from '../../ethereum/market/vote'
import { createAuthenticateCaller } from './authenticate'
import { createNameCaller } from './name'
import { createBehaviorCaller } from '../../ethereum/market/behavior'
import { createGetAuthenticatedPropertiesCaller } from './getAuthenticatedProperties'
import { FallbackableOverrides } from '../../common/utils/execute'
@@ -26,6 +27,7 @@ export type MarketContract = {
overrides?: FallbackableOverrides
) => Promise<string>
readonly behavior: () => Promise<string>
readonly name: () => Promise<string>
readonly getAuthenticatedProperties: () => Promise<readonly string[]>
}

@@ -38,6 +40,7 @@ export const createMarketContract =
schema: createSchemaCaller(contract),
authenticate: createAuthenticateCaller(contract, provider),
behavior: createBehaviorCaller(contract),
name: createNameCaller(contract),
getAuthenticatedProperties:
createGetAuthenticatedPropertiesCaller(contract),
}
37 changes: 37 additions & 0 deletions lib/l2/market/name.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { createNameCaller } from './name'

describe('name.spec.ts', () => {
describe('createNameCaller', () => {
it('call success', async () => {
const value = 'value'

const contract = {
name: jest.fn().mockImplementation(async () => Promise.resolve(value)),
}

const expected = value

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const caller = createNameCaller(contract as any)

const result = await caller()

expect(result).toEqual(expected)
})

it('call failure', async () => {
const error = 'error'

const contract = {
name: jest.fn().mockImplementation(async () => Promise.reject(error)),
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const caller = createNameCaller(contract as any)

const result = await caller().catch((err) => err)

expect(result).toEqual(error)
})
})
})
16 changes: 16 additions & 0 deletions lib/l2/market/name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ethers } from 'ethers'
import { execute, QueryOption } from '../../common/utils/execute'
import { always } from 'ramda'

export type CreateNameCaller = (
contract: ethers.Contract
) => () => Promise<string>

export const createNameCaller: CreateNameCaller = (contract: ethers.Contract) =>
always(
execute<QueryOption>({
contract,
method: 'name',
mutation: false,
})
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devprotocol/dev-kit",
"version": "5.11.2",
"version": "5.11.3",
"description": "Dev Kit for JavaScript",
"author": "abyssparanoia",
"license": "Apache-2.0",