Skip to content

Commit 4b47ab0

Browse files
2 parents 24a6982 + fbf2c39 commit 4b47ab0

File tree

23 files changed

+784
-492
lines changed

23 files changed

+784
-492
lines changed

.github/actions/setup-subtopia-registry/action.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ runs:
2929
ssh-key: ${{ inputs.ssh-key }}
3030
repository: ${{ inputs.repository }}
3131
path: ${{ inputs.path }}
32+
ref: main
3233
fetch-depth: 1
3334

3435
- name: Set up Python
35-
uses: actions/setup-python@v4
36+
uses: actions/setup-python@v5
3637
with:
3738
python-version: ${{ inputs.python-version }}
3839

.github/workflows/cicd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release'
136136
permissions: write-all
137137
name: Release
138-
needs: [build, lint, unit-tests, deploy-docs]
138+
needs: [build, lint, unit-tests]
139139
runs-on: ubuntu-latest
140140
steps:
141141
- name: Check out repository

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ coverage
3232
docs
3333

3434
.env
35+
36+
debug_traces/
37+
38+
.algokit/
39+
40+
.algokit.toml

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# .prettierignore
2+
node_modules
3+
dist
4+
dist-ssr
5+
*.log
6+
coverage
7+
debug_traces
8+
*.local
9+
docs
10+
changelog.md

CHANGELOG.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
# [1.1.0](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v1.0.1...v1.1.0) (2024-01-05)
1+
# [2.0.0-beta.4](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2024-01-21)
2+
3+
# [2.0.0-beta.3](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v2.0.0-beta.2...v2.0.0-beta.3) (2024-01-21)
4+
5+
# [2.0.0-beta.2](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2024-01-20)
6+
7+
# [2.0.0-beta.1](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v1.1.0...v2.0.0-beta.1) (2024-01-17)
28

39

410
### Features
511

6-
* new method for fetching all subscribers from a product instance ([#38](https://github.com/subtopia-algo/subtopia-js-sdk/issues/38)) ([8fc14db](https://github.com/subtopia-algo/subtopia-js-sdk/commit/8fc14dbdaa2e6d04fb4f470a65d472fbfe3a8b72))
12+
* refactoring contracts to support latest 'token-based' types ([#39](https://github.com/subtopia-algo/subtopia-js-sdk/issues/39)) ([604becc](https://github.com/subtopia-algo/subtopia-js-sdk/commit/604beccc4fc2800b4859368aebf3228b6122dd8f))
713

8-
## [1.0.1](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v1.0.0...v1.0.1) (2023-12-13)
914

15+
### BREAKING CHANGES
16+
17+
* Deprecating interface for old contracts, adding a refined and more flexible setup with Token Based subscriptions.
18+
19+
* refactor: improving project structure; minor refinements
20+
21+
* chore: testing ci
22+
23+
# [1.1.0](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v1.0.1...v1.1.0) (2024-01-05)
24+
25+
### Features
26+
27+
- new method for fetching all subscribers from a product instance ([#38](https://github.com/subtopia-algo/subtopia-js-sdk/issues/38)) ([8fc14db](https://github.com/subtopia-algo/subtopia-js-sdk/commit/8fc14dbdaa2e6d04fb4f470a65d472fbfe3a8b72))
28+
29+
## [1.0.1](https://github.com/subtopia-algo/subtopia-js-sdk/compare/v1.0.0...v1.0.1) (2023-12-13)
1030

1131
### Bug Fixes
1232

13-
* bug fixing the renewal flow ([#34](https://github.com/subtopia-algo/subtopia-js-sdk/issues/34)) ([c04285b](https://github.com/subtopia-algo/subtopia-js-sdk/commit/c04285b654c80ae58e7866ab5c98a3c98e04128d))
33+
- bug fixing the renewal flow ([#34](https://github.com/subtopia-algo/subtopia-js-sdk/issues/34)) ([c04285b](https://github.com/subtopia-algo/subtopia-js-sdk/commit/c04285b654c80ae58e7866ab5c98a3c98e04128d))
1434

1535
# 1.0.0 (2023-11-30)
1636

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ yarn add subtopia-js-sdk
3939
### Import the package:
4040

4141
```ts
42-
import {
43-
SubtopiaClient,
44-
SubtopiaRegistryClient,
45-
ChainType,
46-
} from "subtopia-js-sdk";
42+
import { SubtopiaClient, SubtopiaRegistryClient } from "subtopia-js-sdk";
4743
```
4844

4945
## 🛠️ Usage
@@ -55,18 +51,24 @@ Example snippets of using the Subtopia JS SDK.
5551
### Purchasing a subscription:
5652

5753
```ts
54+
import {
55+
SubtopiaClient,
56+
SubtopiaRegistryClient,
57+
ChainType,
58+
SUBTOPIA_REGISTRY_ID
59+
} from "subtopia-js-sdk";
5860
// ... your code
5961

6062
const subtopiaClient = await SubtopiaClient.init({
6163
algodClient: PUT_ALGOD_INSTANCE_HERE,
6264
chainType: PUT_CHAIN_TYPE_ENUM_HERE // 'testnet'|'mainnet'|'localnet'
6365
productID: PUT_PRODUCT_ID_HERE,
66+
registryID: SUBTOPIA_REGISTRY_ID(ChainType.{YOUR_CHAIN_TYPE_HERE}),
6467
creator: { addr: PUT_WALLET_ADDRESS, signer: PUT_WALLET_SIGNER },
6568
});
6669

6770
const response = await subtopiaClient.createSubscription(
68-
{ addr: PUT_WALLET_ADDRESS, signer: PUT_WALLET_SIGNER },
69-
PUT_DURATION_HERE // pick duration from Duration enum. If there is a discount available for this duration, it will be auto applied.
71+
{ subscriber: { addr: PUT_WALLET_ADDRESS, signer: PUT_WALLET_SIGNER } },
7072
);
7173

7274
console.log(response.txID); // response is of type string
@@ -80,6 +82,7 @@ console.log(response.txID); // response is of type string
8082
// ... your code
8183
const subscriptionRecord = await subtopiaClient.getSubscription({
8284
subscriberAddress: PUT_SUBSCRIBER_ADDRESS,
85+
algodClient: PUT_ALGOD_INSTANCE_HERE,
8386
});
8487

8588
// SubscriptionRecord (throws Error if not subscribed)
@@ -91,11 +94,12 @@ console.log(subscriptionRecord);
9194

9295
```ts
9396
// ... your code
94-
const deleteResult = await subtopiaClient.unsubscribe({
97+
const deleteResult = await subtopiaClient.deleteSubscription({
9598
subscriber: {
9699
addr: PUT_SUBSCRIBER_ADDRESS,
97100
signer: PUT_SUBSCRIBER_SIGNER,
98101
},
102+
subscriptionID: PUT_SUBSCRIPTION_ID,
99103
});
100104

101105
// Transaction ID of the unsubscribe transaction
@@ -135,8 +139,6 @@ const subtopiaRegistryClient = await SubtopiaRegistryClient.init({
135139
});
136140

137141
const discount = await subtopiaRegistryClient.createDiscount({
138-
productID: PUT_PRODUCT_ID_HERE, // number - the ID of the Product instance you want to create a discount for
139-
duration: PUT_DURATION_HERE, // number - the type of duration to apply. Also serves as static id for the discount.
140142
discountType: PUT_DISCOUNT_TYPE_HERE, // number - the type of discount to apply. FIXED or PERCENTAGE
141143
discountValue: PUT_DISCOUNT_VALUE_HERE, // number - the discount to be deducted from the subscription price
142144
expiresIn: PUT_EXPIRATION_TIME_HERE, // (Optional) Set 0 for discount to never expire. Else set number of seconds to append to unix timestamp at time of creation.
@@ -152,12 +154,9 @@ console.log(discount.txID); // response is of type string
152154
```ts
153155
// ... your code
154156

155-
const discount = await subtopiaRegistryClient.getDiscount(
156-
productID: PUT_PRODUCT_ID_HERE,
157-
duration: PUT_DURATION_HERE,
158-
);
157+
const discount = await subtopiaClient.getDiscount();
159158

160-
// DiscountRecord (throws Error if not found)
159+
// DiscountRecord (throws Error if no active discount)
161160
console.log(discount);
162161
// ... rest of your code
163162
```
@@ -167,10 +166,7 @@ console.log(discount);
167166
```ts
168167
// ... your code
169168

170-
const deleteResult = await subtopiaRegistryClient.deleteDiscount({
171-
productID: PUT_PRODUCT_ID,
172-
duration: PUT_DURATION_HERE,
173-
});
169+
const deleteResult = await subtopiaRegistryClient.deleteDiscount();
174170

175171
// Transaction ID of the delete discount transaction
176172
console.log(deleteResult.txID);

package-lock.json

Lines changed: 23 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "subtopia-js-sdk",
3-
"version": "1.1.0",
3+
"version": "2.0.0-beta.4",
44
"description": "Subtopia SDK for JavaScript",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.es.js",
@@ -28,14 +28,14 @@
2828
"pre-commit": "npm run lint:scripts && npm run format:scripts && npm run test:integration && npm run build && npm run docs"
2929
},
3030
"peerDependencies": {
31-
"@algorandfoundation/algokit-utils": "^5.0.0",
31+
"@algorandfoundation/algokit-utils": "5.0.1",
3232
"algosdk": "^2.7.0"
3333
},
3434
"devDependencies": {
3535
"@feki.de/semantic-release-yarn": "1.0.1",
3636
"@semantic-release/changelog": "6.0.3",
3737
"@semantic-release/git": "10.0.1",
38-
"@types/node": "^18.13.0",
38+
"@types/node": "^20.0.0",
3939
"@types/react": "^18.0.26",
4040
"@types/react-dom": "^18.0.9",
4141
"@typescript-eslint/eslint-plugin": "^5.46.0",

0 commit comments

Comments
 (0)