Skip to content

Commit

Permalink
Sound.xyz SDK v4 (#277)
Browse files Browse the repository at this point in the history
* move prev sdk new pkg

* prettier write

* ethers v5

* fix versions

* progress

* progress

* verbatim

* remove hardhat

* remove pull-env

* fix

* fix explicit types

* fix isSoundEdition

* remove
  • Loading branch information
PabloSzx authored Oct 17, 2023
1 parent 22c76cf commit e8d39c8
Show file tree
Hide file tree
Showing 62 changed files with 4,546 additions and 15,842 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-rocks-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soundxyz/sdk': major
---

Major rework Sound.xyz SDK v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ yarn-error.log
!.env.vault

cache
packages/sdk/src/api/graphql/gql.ts
packages/sdk-viem/src/api/graphql/gql.ts
2 changes: 2 additions & 0 deletions .graphqlrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema:
- ./schema.graphql
14 changes: 7 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
"mint": "bob-tsm src/mint.ts"
},
"dependencies": {
"@soundxyz/tiered-sdk-viem": "workspace:^",
"@soundxyz/sdk": "workspace:^",
"@soundxyz/sound-protocol": "^1.7.0",
"alchemy-sdk": "^2.9.2",
"@soundxyz/tiered-sdk-viem": "workspace:^",
"alchemy-sdk": "^2.10.1",
"date-fns": "^2.30.0",
"ethers": "^5.7.2",
"require-env-variable": "^4.0.1"
"require-env-variable": "^4.0.2"
},
"devDependencies": {
"@types/node": "20.4.5",
"@types/node": "20.8.6",
"bob-tsm": "^1.1.2",
"dotenv": "^16.3.1",
"esbuild": "^0.18.17",
"typescript": "5.1.6",
"undici": "^5.22.1"
"esbuild": "^0.19.4",
"typescript": "5.2.2",
"undici": "^5.26.3"
}
}
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
"codegen": "pnpm -r --filter=sdk-subgraph codegen",
"format": "prettier . --write",
"postinstall": "husky install",
"prettier:write": "prettier \"**/*.{ts,tsx,mjs,cjs,js}\" --write",
"pretty-quick": "pretty-quick --staged",
"release": "pnpm -r --access=public publish --no-git-checks",
"release:canary": "(node scripts/canary-release.js && pnpm -r publish --access public --no-git-checks --tag alpha) || echo Skipping Canary...",
"test": "pnpm -r --filter=sdk test",
"test": "pnpm -r --filter=sdk --filter=old-sdk test",
"tsc": "tsc -p tsconfig.json",
"typecheck": "pnpm tsc"
},
Expand All @@ -39,21 +40,21 @@
"@changesets/cli": "2.26.2",
"@changesets/config": "^2.3.1",
"@changesets/read": "^0.5.9",
"@manypkg/get-packages": "^1.1.3",
"@types/node": "20.4.5",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"@manypkg/get-packages": "^2.2.0",
"@types/node": "20.8.6",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"dotenv-vault": "^1.25.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"rimraf": "^5.0.1",
"lint-staged": "^15.0.1",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"semver": "^7.5.4",
"typescript": "5.1.6",
"vitest": "^0.34.1"
"typescript": "5.2.2",
"vitest": "^0.34.6"
},
"packageManager": "pnpm@8.0.0",
"engines": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions packages/old-sdk/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License Copyright (c) 2022 Sound.xyz

Permission is hereby granted, free of
charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice
(including the next paragraph) shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions packages/old-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sound.xyz SDK

Visit [https://docs.sound.xyz](https://docs.sound.xyz) for more information
96 changes: 96 additions & 0 deletions packages/old-sdk/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// @ts-check

import { buildCode } from 'bob-ts'
import { execSync, spawn } from 'child_process'
import { writeFile, readFile, copyFile, mkdir } from 'fs/promises'

execSync('pnpm graphql-codegen', {
stdio: 'inherit',
})

spawn(`pnpm tsc -p tsconfig.build.json`, {
stdio: 'inherit',
shell: true,
})

await mkdir('dist').catch(() => null)

const [pkgString] = await Promise.all([
readFile('package.json', 'utf-8'),
buildCode({
entryPoints: ['src'],
clean: true,
format: 'interop',
outDir: 'dist',
target: 'es2019',
sourcemap: false,
}),
copyFile('README.md', 'dist/README.md'),
copyFile('LICENSE', 'dist/LICENSE'),
])

/**
* @type {{name: string, version: string, exports: Record<string,{types: string; require: string; import: string} | string>; main: string; module: string; types: string; sideEffects: false; author: string, license: string, dependencies: Record<string,string>; peerDependencies: Record<string,string>} & Record<string, unknown>}
*/
const {
name,
version,
exports: pkgExports,
main,
module: modulePkg,
types,
sideEffects,
author,
dependencies,
peerDependencies,
license,
scripts,
devDependencies,
publishConfig,
...rest
} = JSON.parse(pkgString)

const exports = {}

function cleanDistPrefix(
/**
* @type {string}
*/
path,
) {
return path.replace('./dist', '.')
}

for (const [key, value] of Object.entries(pkgExports)) {
if (typeof value === 'string') {
exports[key] = cleanDistPrefix(value)
} else {
exports[key] = {
types: cleanDistPrefix(value.types),
require: cleanDistPrefix(value.require),
import: cleanDistPrefix(value.import),
}
}
}

await writeFile(
'dist/package.json',
JSON.stringify(
{
name,
version,
main: cleanDistPrefix(main),
module: cleanDistPrefix(modulePkg),
types: cleanDistPrefix(types),
exports,
sideEffects,
author,
license,
dependencies,
peerDependencies,
...rest,
},
null,
2,
),
)
40 changes: 40 additions & 0 deletions packages/old-sdk/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
schema: '../../schema.graphql'
documents:
- './graphql/**/*.gql'
generates:
./src/api/graphql/gql.ts:
plugins:
- typescript
- typescript-operations
- typescript-document-nodes
config:
useTypeImports: true
enumsAsConst: true
skipTypename: true
namingConvention: 'keep'
preResolveTypes: true
onlyOperationTypes: true
strictScalars: true
avoidOptionals:
field: true
object: false
scalars:
DateTime: 'string'
NonNegativeInt: 'number'
PositiveInt: 'number'
JSON: 'unknown'
Timestamp: 'number'
Void: 'null'
UUID: 'string'
CountryCode: 'string'
NonEmptyString: 'string'
URL: 'string'
EmailAddress: 'string'
Address: 'string'
ENS: 'string'
JWT: 'string'
SemanticVersion: 'string'
documentMode: 'string'
hooks:
afterAllFileWrite:
- pnpm prettier --write
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/old-sdk/graphql/test.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
query Test {
__typename
}
File renamed without changes.
91 changes: 91 additions & 0 deletions packages/old-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"name": "@soundxyz/old-sdk",
"private": true,
"version": "3.0.0",
"homepage": "https://docs.sound.xyz",
"repository": {
"type": "git",
"url": "https://github.com/soundxyz/sdk",
"directory": "packages/sdk"
},
"license": "MIT",
"author": "Sound.xyz",
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./*": {
"types": "./dist/*.d.ts",
"require": "./dist/*.js",
"import": "./dist/*.mjs"
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"prepack": "node build.mjs",
"prepare": "node build.mjs",
"postpublish": "gh-release",
"validate": "graphql-inspector validate \"./graphql/*.gql\" \"./schema.graphql\" --deprecated"
},
"dependencies": {
"@ethersproject/abstract-provider": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/address": "^5.7.0",
"keccak256": "^1.0.6",
"zod": "^3.22.4"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/sha2": "^5.7.0",
"@ethersproject/solidity": "^5.7.0",
"@ethersproject/units": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/core": "^4.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-document-nodes": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-inspector/cli": "^4.0.2",
"@graphql-inspector/config": "^4.0.1",
"@graphql-tools/utils": "^10.0.7",
"@soundxyz/sound-protocol": "^1.7.0",
"@soundxyz/sound-protocol-v1-0": "npm:@soundxyz/sound-protocol@1.1.0",
"@soundxyz/sound-protocol-v1-1": "npm:@soundxyz/sound-protocol@1.3.0",
"@types/chai": "^4.3.8",
"@types/mocha": "^10.0.2",
"@types/node": "20.8.6",
"bob-ts": "^4.1.1",
"bob-tsm": "^1.1.2",
"chai": "^4.3.10",
"changesets-github-release": "^0.1.0",
"dotenv": "^16.3.1",
"esbuild": "^0.19.4",
"ethereum-waffle": "^4.0.10",
"ethers": "^5.7.2",
"graphql": "^16.8.1",
"merkletreejs": "^0.3.10",
"prettier": "^3.0.3",
"require-env-variable": "^4.0.2",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"typescript": "5.2.2"
},
"peerDependencies": {
"@soundxyz/sound-protocol": "~1.7.0"
},
"publishConfig": {
"access": "public",
"directory": "dist",
"linkDirectory": true
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/old-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { SoundClient } from './client/main'

export * as Errors from './errors'
export * from './types'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/old-sdk/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion packages/sdk-viem/codegen.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
schema: './schema.graphql'
schema: '../../schema.graphql'
documents:
- './graphql/**/*.gql'
generates:
Expand Down
Loading

0 comments on commit e8d39c8

Please sign in to comment.